【发布时间】:2016-04-09 00:42:15
【问题描述】:
我需要做的任务是让 CDN 依赖于 S3 存储桶。但我们想让它使用现有的存储桶,而不是创建一个新存储桶。
这是我正在尝试的示例代码:
"Parameters" : {
"UseExistingBucket" : {
"Description" : "Yes/No",
"Default" : "yes",
"Type" : "String",
"AllowedValues" : [ "yes", "no" ]
}
},
"Conditions" : {
"CreateS3Resources" : {"Fn::Equals" : [{"Ref" : "UseExistingBucket"}, "no"]}
},
"Resources" : {
"StaticBucket" : {
"Type" : "AWS::S3::Bucket",
"Condition" : "CreateS3Resources",
"Properties" : {
"BucketName" : { "Fn::Join": [ "-", [ "app", { "Ref": "EnvType" }, "static" ] ] }
},
"DeletionPolicy": "Retain"
},
"MyStaticDistribution": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"Origins": [
{
"DomainName": {
"Fn::If" : [
"CreateS3Resources",
{ "Fn::Join": [ "-", [ "app", { "Ref": "EnvType" }, "static" ] ] },
{"Fn::GetAtt": [ "StaticBucket", "DomainName" ] }
]
},
"Id": "S3Origin",
}
]
}
},
"DependsOn": [{
"Fn::If" : [
"CreateS3Resources",
{ "Fn::Join": [ "-", [ "app", { "Ref": "EnvType" }, "static" ] ] },
""
]
}]
}
}
如果需要,请向我建议更多详细信息(至少 stackoverflow 确实需要更多详细信息,但我没有指定任何:-P)
【问题讨论】:
标签: amazon-web-services amazon-s3 amazon-cloudformation