Lab 01: Template and Stack
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:
- Write a simple CloudFormation template that describes an S3 bucket.
- Deploy the template and create a CloudFormation stack.
- Go to the
- Open 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
- 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.
- Click Next.
- Provide a Stack name. For example cfn-workshop-s3.
- The Stack name identifies the stack. Use a name to help you distinguish the purpose of this stack.
- Click Next.
- You can leave Configure stack options default, click Next.
- On the Review 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.
- Create a property
VersioningConfiguration in the
Properties section of the S3 resource.
- Set the
- Update the stack to reflect the changes made in the template.
Want to see the solution?
- Replace the code in your template with the code below:
Update the stack as per demo below:
Follow these steps to clean up created resources:
- In in the CloudFormation console, select the the stack you have created in this lab. For example
- In the top right corner, click on Delete.
- In the pop up window click on Delete stack.
- You can click the refresh button a few times until you see in the status DELETE_COMPLETE.
Great work! You have written your first CloudFormation template and created your first stack.