DEV Community

Cover image for Automate Start/Stop/Delete/Create AWS synthetic canaries
Harinder Seera 🇭🇲 for AWS Community Builders

Posted on • Updated on

Automate Start/Stop/Delete/Create AWS synthetic canaries

This is the second post in the series. This guide will walk you through starting, stopping, deleting, and creating a synthetic canary. Useful if you want to automate the process of producing canaries as part of your devops pipeline or if you don't want to log into the AWS console every time you want to create, start, stop or delete a canary.

All of this can be achieved with the Python script I developed using AWS Python SDK and shared on github. The script's current version allows you to do the following:

  • Start & Stop All Canaries
  • Start & Stop a Canary
  • Delete a Canary
  • Script Runtime Versions
  • Create a Canary

Start & Stop All Canaries

To Start & Stop all canaries, run the script with the following command.

./synthetic_canary.py stop
./synthetic_canary.py start
Enter fullscreen mode Exit fullscreen mode

Start & Stop A Canary

To Start & Stop a canary, run the script with the following command.

./synthetic_canary.py stop/start {canary name}
Enter fullscreen mode Exit fullscreen mode

Example

./synthetic_canary.py stop workload
./synthetic_canary.py start workload
Enter fullscreen mode Exit fullscreen mode

Delete A Canary

To delete a canary, run the script with the following command.

./synthetic_canary.py delete {canary name}
Enter fullscreen mode Exit fullscreen mode

Example

./synthetic_canary.py delete workload
Enter fullscreen mode Exit fullscreen mode

Script Runtime Versions

Returns a list of Synthetics canary runtime versions and their dependencies. When creating a canary, you must pass in the script runtime version. Make this call first, then extract the appropriate version to use for the create canary script.

./synthetic_canary.py runtime
Enter fullscreen mode Exit fullscreen mode

Create A Canary

To create a canary, run the script with the following command.

./synthetic_canary.py create {canary name}
Enter fullscreen mode Exit fullscreen mode

Example

./synthetic_canary.py create workload
Enter fullscreen mode Exit fullscreen mode

A sample python GET api canary blueprint script is also included in the github repo to assist you to get started with developing an api synthetic canary. For it to work in your environment, you must change the script with the correct api end point and headers. Make sure you follow the correct folder structure when uploading the zip nodejs or python canary script to S3.

Hopefully, this script will come in handy to you in the aforementioned case. Keep an eye out for the script updates as I add new features. Contact me if you would like to contribute to the code. Also, leave a comment or a star on the git repo if you find the script useful.

Note: Before using the script in production, try it in your development/test environment first.


Thanks for reading!

If you enjoyed this article feel free to share it on social media 🙂

Say Hello on: Linkedin | Twitter | Polywork

Blogging: Dev | Hashnode

Github: hseera

Discussion (0)