Can I connect to CloudWatch using Python?

Writing a Python canary script

This script is passed as a successful execution and returns a string. To see what a buggy Canary looks like, change fail = False to fail = True

If you have more than one .py file or dependency, you can bundle them all into a single zip file. The zip file must be your main Canary .py file inside a folder, e.g. B. from. This zip file should contain all the necessary folders and files, but the other files do not need to be imfolder.

Set your Canary's script entry point as to match the script entry point filename.

Modifying an Existing Selenium Script to Use a Synthetics Canary

You can quickly modify an existing Python and Selenium script to be used as a canary. You can find more information about selenium at

In this example we start with the following Selenium script:

The conversion steps are as follows.

How to Convert a Selenium Script as a Canary

  1. Change the Option statement to use Selenium from the module:

    The Selenium module from ensures that the canary can output metrics and logs, generate a HAR file and work with other CloudWatch Synthetics functions.

  2. Create a handler function and call your Selenium method. The handler is the entry function for the script.

The script is now updated as the CloudWatch Synthetics Canary. Below is the updated script:

Write a "Node.js canary" script
Library functions for Canarian scripts