Understanding CloudFormation Template Anatomy

Hands-On Lab

 

Photo of Craig Arcuri

Craig Arcuri

AWS Training Architect II in Content

Length

01:15:00

Difficulty

Intermediate

This lab takes an in-depth look at CloudFormation template anatomy. Each section of a CloudFormation template will be covered in detail, and, ultimately, a CloudFormation template will be constructed piece by piece. After completing this lab, the student will have a deeper understanding of constructing CloudFormation templates in both JSON and YAML.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Understanding CloudFormation Template Anatomy

Introduction

This lab takes an in-depth look at CloudFormation template anatomy. Each section of a CloudFormation template will be covered in detail, and, ultimately, a CloudFormation template will be constructed piece by piece. After completing this lab, the student will have a deeper understanding of constructing CloudFormation templates in both JSON and YAML.

Solution

Log in with the credentials provided, and make sure you are in the us-east-1 (N. Virginia) region.

Download the templates used in the lab here.

Create a CloudFormation Stack

  1. Navigate to CloudFormation.
  2. Click Create stack.
  3. In the Prerequisite - Prepare template section, select Create template in Designer.
  4. Click Create template in designer.
  5. Click the Template tab at the bottom.
  6. Copy everything in the Template_Anatomy2.yaml file, and paste it into the Template window.
  7. In a new browser tab, navigate to EC2 > Key Pairs.
  8. Click Create Key Pair.
  9. Give it a key pair name of "tempanatomy", and click Create.
  10. Click Security Groups in the left-hand menu.
  11. Copy the security group ID and paste it into a text file, since we'll need it in a minute.
  12. Navigate to VPC > Subnets.
  13. Select one of the listed subnets, and copy its subnet ID. Paste it into a text file, since we'll also need it later.
  14. Back in the CloudFormation template window, click the checkbox at the top to validate the template, and then click the cloud icon with the up arrow to create the stack.
  15. Click Next.
  16. On the stack details page, set the following values:
    • Stack name: tempanatomyLab
    • InstanceType: t2.micro
    • KeyName: tempanatomy
    • MySG: Paste in the security group ID you copied earlier
    • MySubnet: Paste in the subnet ID you copied earlier
  17. Click Next.
  18. On the stack options page, set the Key as "name" and Value as "tempanatomy".
  19. Click Next.
  20. Click Create stack. It will take a few minutes for it to fully be created.

Delete a CloudFormation Stack

  1. Once it's created, click Delete at the top.
  2. In the confirmation dialog, click Delete stack.
  3. Monitor the deletion process by watching the Events tab.

Conclusion

Congratulations on successfully completing this hands-on lab!