Creating your first stack
I'm sure you've done this before.
We begin by developing our template first. This is going to be a simple S3 bucket. I'm going to use YAML template formatting, but you may use JSON formatting if you wish:
MyBucket.yaml
AWSTemplateFormatVersion: "2010-09-09" Description: This is my first bucket Resources: Â Â MyBucket: Â Â Â Â Type: AWS::S3::Bucket
Now we just need to create the stack with awscli
:
$ aws cloudformation create-stack \ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â --stack-name mybucket\ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â --template-body file://MyBucket.yaml
After a while, we will see our bucket created if we go to the AWS console or run aws s3 ls
.
Now let's add some public access to our bucket:
MyBucket.yaml
AWSTemplateFormatVersion: "2010-09-09" Description: This is my first bucket Resources:   MyBucket:     Type: AWS::S3::Bucket     Properties:       AccessControl: PublicRead
Let's run the update
operation:
$ aws cloudformation update-stack \ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â --stack-name mybucket \ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â --template-body file://MyBucket.yaml
To clean up your workspace, simply delete your stack using the following command:
$ aws cloudformation delete-stack --stack-name mybucket
Let's now look at the CloudFormation IAM permissions.