Using CloudFormation Templates to Create Complex Environments in AWS

Hands-On Lab

 

Photo of Craig Arcuri

Craig Arcuri

AWS Training Architect II in Content

Length

01:30:00

Difficulty

Advanced

In this hands-on lab, the student will work on a scenario in which an existing CloudFormation template is the basis for a new environment. In this scenario, we adapt an existing template to meet our requirements. We compare the original as-is template to the final to-be template and review the steps taken to adapt the original template. The student can then use the to-be template to create the desired resulting stack. This type of adaptation saves a lot of time but may not result in a perfect environment on the first try. The student will be able to troubleshoot the resulting environment to achieve the goal of the Learning Activity; the ability to browse to a functional web application.

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.

Using CloudFormation Templates to Create Complex Environments in AWS

Introduction

In this hands-on lab, we will work on a scenario in which an existing CloudFormation template is the basis for a new environment.

Solution

Log in to the live AWS environment using the credentials provided. Make sure you're in the N. Virginia (us-east-1) region.

On this page in GitHub, download the following:

  • OriginalTemp.json
  • CFLearningActivity.json

To download them, right-click each file and select Save as.

For an in-depth look at the files, make sure to watch the "Walkthrough of the CloudFormation Template" video on the lab page.

Create a CloudFormation Stack

  1. Navigate to CloudFormation.
  2. Click Design template.
  3. In the Parameters section below, click the Template tab.
  4. Delete the existing code, and paste in the code in the CFLearningActivity.json file.
  5. Click the checkmark icon in the upper left to validate it.
  6. Open a new browser tab, and navigate to EC2.
  7. Click Key Pairs in the left-hand menu.
  8. Click Create Key Pair.
  9. Give it a name of "cftemp".
  10. Click Create.
  11. Back on the stack creation page, click the upload icon in the upper left to create the stack.
  12. On the Select Template page, click Next.
  13. On the Specify Details page, set the following values:
    • Stack name: cftempadaption
    • InstanceType: t2.micro
    • KeyName: cftemp
    • OperatorEmail: Enter your email address
    • Subnets: A public and B public
    • VpcId: Select the one listed
  14. Click Next.
  15. On the Options page, leave the settings as-is, and click Next.
  16. Click Create.
  17. Refresh the stacks page to see our new one.
  18. With our new stack selected, click the Events dropdown, and select Outputs.
  19. Right-click the URL listed, and open it in a new browser tab. The site doesn't seem to be loading.

Troubleshoot the Issue

  1. In the EC2 management console, check the instances, load balancers, and target groups. Everything seems operational.
  2. Navigate to VPC.
  3. Check targets and health checks. All is well there.
  4. Go back to the load balancer dashboard.
  5. In the Description section below, we'll see it has a default security group.
  6. Click Edit security groups.
  7. In the dialog, select the cftempadaption-InstanceSecurityGroup listed, and click Save.
  8. Refresh the web app browser tab. It should instantly load.

Conclusion

Congratulations on completing this hands-on lab!