Skip to main content

A Python package to indicate if this EC2 instance should be the one and only to perform a task within an auto-scaling group.

Project description



A Python package to indicate if an AWS EC2 instance is the one and only appointed to perform a special task within an auto-scaling group.


Let's say you've got a fleet of EC2 instances, deployed via an auto-scaling group, all serving web content from a shared network drive.

Now, let's say you want to appoint one of those EC2 instances to be the one and only to backup the shared content to another location.

If the launch configuration set up every instance to perform the backup then they could all end up tramping over each other, and there'd be a ton of wasted traffic. If you manually configured one as a special case to perform the backup, then what happens when that instance goes down?

(Of course, you might decide to have a totally separate EC2 instance connect to the network drive to perform the backup, so that your web servers don't hold multiple responsibilities. This would be a good idea. I'm assuming that your project ain't worth that level of infrastructure, and you're happy with instances holding multiple responsibilities.)

chesney solves this problem by ensuring it returns true for only one EC2 instance within an auto-scaling group, and false for all the rest. This means you can configure all of your instances to -- for example -- perform a daily check to see if they're the one and only, and then initiate the backup only if they are.


pip install chesney

Command-line usage

python -m chesney [--log-level LEVEL]

Will return either true or false.

Code usage

import chesney

if chesney.is_appointed():
    # Do the thing
    # Don't do the thing.


You must run chesney with the following permissions:

  • autoscaling:DescribeAutoScalingGroups
  • ec2:DescribeInstances

An IAM policy would look something like this:

PolicyName: AllowChesney
    - Effect: Allow
        - "autoscaling:DescribeAutoScalingGroups"
        - "ec2:DescribeInstances"
        - "*"



chesney requires Python 3.x.

Installing dependencies

pip install -e .[dev]

Running tests



v1.0 - 2018-12-03

  • Initial release.

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for chesney, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size chesney-1.0-py3-none-any.whl (6.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size chesney-1.0.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page