AWS CloudFormation
User Guide (API Version 2010-05-15)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

AWS::S3::Bucket

The AWS::S3::Bucket type creates an Amazon S3 bucket.

You can set a deletion policy for your bucket to control how AWS CloudFormation handles the bucket when the stack is deleted. For Amazon S3 buckets, you can choose to retain the bucket or to delete the bucket. For more information, see DeletionPolicy Attribute.

Important

Only Amazon S3 buckets that are empty can be deleted. Deletion will fail for buckets that have contents.

Syntax

{
   "Type" : "AWS::S3::Bucket",
   "Properties" : {
      "AccessControl" : String,
      "BucketName" : String,
      "Tags" : [ Resource Tag, ... ],
      "WebsiteConfiguration" : Website Configuration Type
   }
}     

Properties

AccessControl

A canned access control list (ACL) that grants predefined permissions to the bucket. For more information about canned ACLs, see Canned ACLs in the Amazon S3 documentation.

Required: No

Type: String

Valid values: Private | PublicRead | PublicReadWrite | AuthenticatedRead | LogDeliveryWrite | BucketOwnerRead | BucketOwnerFullControl

Update requires: no interruption

BucketName

A name for the bucket. If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the bucket name. For more information, see Name Type. The bucket name must contain only lowercase letters, numbers, periods (.), and dashes (-).

Important

If you specify a name, you cannot do updates that require this resource to be replaced. You can still do updates to this resource if the update requires no or some interruption.

Required: No

Type: String

Update requires: Replacement
Tags

An arbitrary set of tags (key-value pairs) for this Amazon S3 bucket.

Required: No

Type: AWS CloudFormation Resource Tags

Update requires: no interruption

WebsiteConfiguration

Information used to configure the bucket as a static website. For more information, see Hosting Websites on Amazon S3.

Required: No

Type: Website Configuration Type

Update requires: no interruption

Example:

"WebsiteConfiguration" : {
   "IndexDocument" : "index.html", "ErrorDocument" : "error.html" }

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, it returns the resource name.

Example: mystack-mybucket-kdwwxmddtr2g

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. This section lists the available attributes and corresponding return values.

DomainName

Returns the DNS name of the specified bucket.

Example: mystack-mybucket-kdwwxmddtr2g.s3.amazonaws.com

WebsiteURL

Amazon S3 website endpoint for the specified bucket.

Example: http://mystack-mybucket-kdwwxmddtr2g.s3-website-us-east-1.amazonaws.com/

For more information about using Fn:GetAtt, see Fn::GetAtt.

Examples

Example Basic static website configuration with an index and error document

In this example, AWS::S3::Bucket's Fn::GetAtt values are used to provide outputs.

"Resources" : {
   "S3Bucket" : {
      "Type" : "AWS::S3::Bucket",
      "Properties" : {
         "AccessControl" : "PublicRead",
         "BucketName" : "PublicBucket",
         "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"
   }
}        

For more examples, see Amazon S3 Template Snippets.

See Also