DEPLOY A RELIABLE MULTI-TIER INFRASTRUCTURE USING CLOUDFORMATION

Tim Okito
4 min readAug 4, 2020

Today, I will show you the steps to improve reliability of a service by using automation to deploy a reliable cloud infrastructure.

Log into the AWS Console and search for Cloudformation under services.

Click Create Stack, then With new resources (standard).

Click Upload a template file and then click Choose file.

Click Next

Enter the following details:

  • Stack name: The name of this stack. For this lab, use WebApp1-VPC and match the case.
  • Parameters: Parameters may be left as defaults, you can find out more in the description for each.

At the bottom of the page click Next.

Review the information for the stack. When you’re satisfied with the configuration, at the bottom of the page check I acknowledge that AWS CloudFormation might create IAM resources with custom names then click Create stack.

After a few minutes the final stack status should change from CREATE_IN_PROGRESS to CREATE_COMPLETE. You can click the refresh button to check on the current status. You have now created the VPC stack (well actually CloudFormation did it for you).

Wait until the VPC CloudFormation stack status is CREATE_COMPLETE, then continue. This will take about four minutes.

Now that your stack created, we are now going to the next steps to deploy a web application Cloudformation.

Go to the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation and click Create Stack > With new resources.

Leave Prepare template setting as-is.

  • For Template source select Upload a template file
  • Click Choose file and supply the CloudFormation template you

Click Next

For Stack name use CloudformationLab

Parameters

  • Look over the Parameters and their default values.
  • Click Next

Click Next

For Review

  • Review the contents of the page
  • At the bottom of the page, select I acknowledge that AWS CloudFormation might create IAM resources with custom names
  • Click Create stack

This will take you to the CloudFormation stack status page, showing the stack creation in progress.

  • Click on the Events tab
  • Scroll through the listing. It shows (in reverse order) the activities performed by CloudFormation, such as starting to create a resource and then completing the resource creation.
  • Any errors encountered during the creation of the stack will be listed in this tab.

Wait until it shows the Status of CREATE_COMPLETE, then you are finished with this step.

  • Click on the CloudFormationLab stack
  • Click on the Outputs tab
  • For the Key Website URL copy the value. This is the URL of your test web service
  • Click the URL and it will bring up the website

Refresh the website several times, note that the EC2 instance and Availability Zone change from among the three available.

Click on the CloudFormation stack that you deployed

Click on the Template tab

The template is written in a format called YAML, which is commonly used for configuration files. CloudFormation templates can also be written in JSON.

The Resources section is the “heart” of the template. It is where you define the infrastructure to be deployed. Look at the first resource defined.

TEAR DOWN THIS LAB

In order to avoid unnecessary charges we will tear down this lab.

Go to the AWS CloudFormation console: https://console.aws.amazon.com/cloudformation

Select the CloudFormation stack to delete and click Delete

In the confirmation dialog, click Delete stack

The Status changes to DELETE_IN_PROGRESS

Click the refresh button to update and status will ultimately progress to DELETE_COMPLETE

When complete, the stack will no longer be displayed. To see deleted stacks use the drop down next to the Filter text box.

To see progress during stack deletion

  • Click the stack name
  • Select the Events column
  • Refresh to see new events

Delete workshop CloudFormation stacks

  1. First delete the CloudFormationLab CloudFormation stack
  2. Wait for the CloudFormationLab CloudFormation stack to complete
  3. Then delete the WebApp1-VPC CloudFormation stack

--

--