| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
This section contains a number of template snippets specific to Amazon S3 using the AWS::S3::Bucket type.
Topics
This example uses a AWS::S3::Bucket to create a bucket with default settings.
"myS3Bucket" : {
"Type" : "AWS::S3::Bucket"
}This example creates a bucket as a website. The AccessControl property is set to the canned ACL
PublicRead (public read permissions are required for buckets set up for website hosting). Because this
bucket resource has a DeletionPolicy attribute set to
Retain, AWS CloudFormation will not delete this bucket when it deletes the stack. The Output
section uses Fn::GetAtt to retrieve the WebsiteURL attribute and DomainName attribute
of the S3Bucket resource.
"{
"AWSTemplateFormatVersion" : "2010-09-09",
"Resources" : {
"S3Bucket" : {
"Type" : "AWS::S3::Bucket",
"Properties" : {
"AccessControl" : "PublicRead",
"WebsiteConfiguration" : {
"IndexDocument" : "index.html",
"ErrorDocument" : "error.html"
}
},
"DeletionPolicy" : "Retain"
}
},
"Outputs" : {
"WebsiteURL" : {
"Value" : { "Fn::GetAtt" : [ "S3Bucket", "WebsiteURL" ] },
"Description" : "URL for website hosted on S3"
},
"S3BucketSecureURL" : {
"Value" : { "Fn::Join" : [ "", [ "https://", { "Fn::GetAtt" : [ "S3Bucket", "DomainName" ] } ] ] },
"Description" : "Name of S3 bucket to hold website content"
}
}
}