Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
93 lines (92 sloc) 2.61 KB
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"DomainName": {
"Type": "String"
},
"IAMDeployUser": {
"Type": "String"
}
},
"Resources" : {
"Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": { "Ref": "DomainName" },
"WebsiteConfiguration": {
"IndexDocument": "index.html",
"ErrorDocument": "404/index.html",
"RoutingRules": [
{
"RoutingRuleCondition": {
"HttpErrorCodeReturnedEquals": "404",
"KeyPrefixEquals": "feed"
},
"RedirectRule": {
"HttpRedirectCode": "301",
"ReplaceKeyWith": "feed.xml"
}
}
]
}
}
},
"WWWBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": { "Fn::Join": [ "", [ "www.", { "Ref": "DomainName" } ] ] },
"WebsiteConfiguration": {
"RedirectAllRequestsTo": {
"HostName": { "Ref": "DomainName" },
"Protocol": "https"
}
}
}
},
"BucketPolicy": {
"Type": "AWS::S3::BucketPolicy",
"DependsOn": "Bucket",
"Properties": {
"Bucket" : { "Ref": "DomainName" },
"PolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [ "s3:GetObject" ],
"Resource": { "Fn::Join": [ "", [ "arn:aws:s3:::", { "Ref": "DomainName" }, "/*" ] ] }
},
{
"Effect": "Allow",
"Principal": {
"AWS": { "Fn::Join": [ "", [ "arn:aws:iam::", { "Ref": "AWS::AccountId" }, ":user/", { "Ref": "IAMDeployUser" } ] ] }
},
"Action": "s3:*",
"Resource": [
{ "Fn::Join": [ "", [ "arn:aws:s3:::", { "Ref": "DomainName" }, "/*" ] ] },
{ "Fn::Join": [ "", [ "arn:aws:s3:::", { "Ref": "DomainName" } ] ] }
]
}
]
}
}
},
"WWWBucketPolicy": {
"Type": "AWS::S3::BucketPolicy",
"DependsOn": "WWWBucket",
"Properties": {
"Bucket": { "Fn::Join": [ "", [ "www.", { "Ref": "DomainName" } ] ] },
"PolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [ "s3:GetObject" ],
"Resource": { "Fn::Join": [ "", [ "arn:aws:s3:::www.", { "Ref": "DomainName" }, "/*" ] ] }
}
]
}
}
}
}
}