A Python package to indicate if this EC2 instance should be the one and only to perform a task within an auto-scaling group.
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
python -m chesney [--log-level LEVEL]
Will return either
import chesney if chesney.is_appointed(): # Do the thing else: # Don't do the thing.
You must run
chesney with the following permissions:
An IAM policy would look something like this:
PolicyName: AllowChesney PolicyDocument: Statement: - Effect: Allow Action: - "autoscaling:DescribeAutoScalingGroups" - "ec2:DescribeInstances" Resource: - "*"
chesney requires Python 3.x.
pip install -e .[dev]
v1.0 - 2018-12-03
- Initial release.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|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|