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.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create a CloudFormation Stack
- Navigate to CloudFormation.
- Click Create stack.
- In the new CloudFormation page, click Designer
- Click the Template tab at the bottom.
- Copy everything in the
Template_Anatomy2.yaml
file, and paste it into the Template window. - In a new browser tab, navigate to EC2 > Key Pairs.
- Click Create Key Pair.
- Give it a key pair name of "tempanatomy", and click Create.
- Click Security Groups in the left-hand menu.
- Copy the security group ID and paste it into a text file, since we’ll need it in a minute.
- Navigate to VPC > Subnets.
- Select one of the listed subnets, and copy its subnet ID. Paste it into a text file, since we’ll also need it later.
- 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.
- Click Next.
- 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
- Click Next.
- On the stack options page, set the Key as "name" and Value as "tempanatomy".
- Click Next.
- Click Create stack. It will take a few minutes for it to fully be created.
- Delete a CloudFormation Stack
- Once the stack is created, click Delete at the top.
- In the confirmation dialog, click Delete stack.
- Monitor the deletion process by watching the Events tab.