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.

Topics Covered

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.

Start Lab

  1. Go to the code/10-cloudformation-fundamentals/ directory.

  2. Open the 01-lab01-StackExample.yaml file in your code editor.

  3. 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 01-lab01-StackExample.yaml file.

        Type: AWS::S3::Bucket
  4. Open the AWS CloudFormation link in a new tab and log in to your AWS account.

  5. Click on Create stack (With new resources (Standard) if you have clicked in the top right corner).

  6. In Prepare template, choose Template is ready.

  7. In Template source, choose Upload a template file.

  8. Click on Choose file button and navigate to your workshop directory.

  9. Select the file 01-lab01-StackExample.yaml referenced in step 1.

  10. Click Next.

  11. 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.
  12. You can leave Configure stack options default, click Next.

  13. On the Review <stack_name> page, scroll down to the bottom and click on Create stack.

  14. 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.

  1. Create a property VersioningConfiguration in the Properties section of the S3 resource.
  2. Set the Status to Enabled.
  3. Update the stack to reflect the changes made in the template.
Need a hint?
Want to see the solution?

Clean up

Follow these steps to clean up created resources:

  1. In the CloudFormation console, select the stack you have created in this lab. For example cfn-workshop-s3.
  2. In the top right corner, click on Delete.
  3. In the pop up window click on Delete stack.
  4. 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.