This lab will start with the most basic template containing only Resources object, which contains a single resource declaration of the S3 bucket.
By the end of this lab, you will be able to:
Go to the
01-lab01-StackExample.yaml file in your code editor.
Here is a sample CloudFormation template that defines an S3 Bucket. It has a single resource that contains the S3 bucket. Copy the code below and save to the
Resources: S3Bucket: Type: AWS::S3::Bucket
Open the AWS CloudFormation link in a new tab and log in to your AWS account.
Click on Create stack (With new resources (Standard) if you have clicked at the top right corner).
In Prepare template, choose Template is ready.
In Template source, choose Upload a template file.
Click on Choose file button and navigate to your workshop directory.
Select the file
01-lab01-StackExample.yaml referenced in step 1.
Provide a Stack name. For example cfn-workshop-s3.
You can leave Configure stack options default, click Next.
On the Review <stack_name> page, scroll down to the bottom and click on Create stack.
You can click the refresh button a few times until you see in the status CREATE_COMPLETE.
In this exercise, enable versioning on the S3 bucket. Enabled versioning will prevent objects from being deleted or overwritten by mistake or to archive objects so that you can retrieve previous versions of them.
Propertiessection of the S3 resource.
Check out the AWS Documentation for AWS::S3::Bucket resource.
Replace the code in your template with the code bellow:
Resources: S3Bucket: Type: AWS::S3::Bucket Properties: VersioningConfiguration: Status: Enabled
Update the stack as per demo bellow:
Follow these steps to clean up created resources:
Great work! You have written your first CloudFormation template and created your first stack.