Using CloudFormation to create a bucket

In this recipe, you will use CloudFormation to create a bucket with resource tags that have been configured to enable cost-center reporting, and with a rule to move the objects to Glacier after 90 days:

  1. Create a file called 03-04-Glacier.yml with the following content:
Resources:
MyCloudFormationBucket:
Type: AWS::S3::Bucket
Properties:
LifecycleConfiguration:
Rules:
- Id: GlacierRule
Prefix: glacier
Status: Enabled
Transitions:
- TransitionInDays: '90'
StorageClass: Glacier
Tags:
-
Key: "COST_CENTER"
Value: "Accounting"
-
Key: "PROJECT_ID"
Value: "FY2019"
Outputs:
BucketName:
Value: !Ref MyCloudFormationBucket
Description: The bucket name
  1. Create the stack:
$ aws cloudformation create-stack 
--stack-name 03-04-Glacier.yml
--template-body file://03-04-Glacier.yml
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset