Skip to main content

Deploying a Website Canary with CloudFormation

Hands-On Lab


Photo of

Training Architect





In this live AWS environment, you will use AWS CloudFormation to deploy your own website Canary application. Website canaries are programs commonly used to monitor the status of sites or services to determine uptime, calculate availability and alert when there are potential failures. Because you will deploy the canary with CloudFormation, you will avoid much of the manual setup that would otherwise be required, and you will be able to describe your AWS infrastructure for this application in a JSON template.

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.

Deploying a Website Canary with CloudFormation


In this lab, we'll use AWS CloudFormation to deploy our own website Canary application.

Log in to the AWS console with the cloud_user credentials provided on the lab page, and make sure you are in us-east-1 throughout the lab.

Once you're logged in, navigate to S3. Then, open CloudFormation in a new browser tab. We'll leave both tabs open as we work with them throughout the lab.

Upload a Lambda Function Zip File Deployment Artifact to S3

First, we're going to upload a deployment zip package to S3 inside the AWS console so our CloudFormation template can rely on it during the creation process.

  1. Navigate to S3.
  2. Click + Create bucket.
  3. On the Name and region screen, give your bucket a globally unique name — in addition to "website-canary-2018-cf-test", you could append your name, favorite animal, and some random letters. Copy the bucket name into a note or text file on your desktop — we'll need it again later. Click Next.
  4. Click Next two more times, leaving the default settings on the subsequent screens, and finally click Create bucket.
  5. Click into the bucket, and click Upload.
  6. Upload the file from the GitHub repository here into the S3 bucket.

Create a CloudFormation Stack

Now, we'll create a CloudFormation stack in the AWS console using the designer and the code samples provided.

  1. Head to the CloudFormation browser tab.
  2. Click Create Stack, and then click Design template.
  3. Select the Template tab of the editor.
  4. Paste in the code from the sample cftemplate.json file here.
  5. In the Code section of the template, enter the name of your bucket where it says "S3Bucket": "REPLACEME".
  6. In the Properties portion of the LambdaCanaryFunction section of the template:
    • Update the site with the name of the website you'd like to check (including https://)
    • Update expected with some text you might expect to see on that site.
    • Update phone with the phone number at which you want to receive a text notification (including + and your country code — e.g., 1 for the United States).
  7. Click the checkbox icon in the top left to validate the template.
  8. Click the upload icon in the top left to create the stack.
  9. This brings us back to the Create stack page we saw in the beginning, but now our Amazon S3 template URL is auto-filled. Click Next.
  10. Give the stack a name (e.g., "cf-test-2018-canary"), and click Next.
  11. We don't need to do any configuration on the Options page, so click Next.
  12. On the Review page, check the box to acknowledge AWS CloudFormation might create IAM resources, and click Create.
  13. If you don't see the stack listed yet, click the refresh icon. It should then show the creation is in progress.

Test the Lambda Function

  1. Navigate to Lambda via the Services menu at the top.
  2. Click into the listed Lambda function.
  3. Click the Select a test event dropdown at the top, and select Configure test events.
  4. In the Event template dropdown, search for "Amazon CloudWatch".
  5. Give it an Event name of "test".
  6. Click Create.
  7. Click Test at the top. You should receive a text message letting you know the check passed.


Congratulations on completing this lab!