Hands on creating a S3 bucket
- We're going to create a simple EC2 instance.
- Then we're going to create to add an Elastic IP to it
- And we're going to add two security groups to it
Implementation
AWS CloudFormation Template reference (opens in a new tab)
Create a S3 bucket.
L03_1-S3_Bucket.yaml
Resources:
MyS3Bucket:
Type: "AWS::S3::Bucket"
Properties: {}
Add access control
We'll consider two types of updates:
Case 01: Updates with no interruption (adding AccessControl)
L03_2-S3_Bucket.yml
Resources:
MyS3Bucket:
Type: "AWS::S3::Bucket"
Properties:
AccessControl: PublicRead
Case 02: Replacements updates, such as updating the name of the bucket.
L03_2-S3_Bucket.yml
Resources:
MyS3Bucket:
Type: "AWS::S3::Bucket"
Properties:
AccessControl: PublicRead
BucketName: "foofoo-bucket-name"
If we try to update the changes. You notice in the preview page it says - Replacement - True
that means it will replace entire bucket with a new one. It result the loss in data.
CloudFormation doesn't create replica by itself to preserve your data, it just do whatever you say. A user will be responsible in case if he/she lose data.