I needed a quick and simple script to monitor some of the API’s I manage. Since I already build in methods that fully test the webservice and backend database, I just had to wrap a single call and check the results from this method. Also I don’t want to rely on my servers being able to send mail, so I added support for AWS SES.
And the code…
Trying to deploy fabric recipes to an auto-scaling group on EC2 could prove pretty painful, except if you have this slick code snippet to define your server group in Fabric.
Basically I’m using boto to list all of the instances currently running in a specific security group, and then populate env.hosts.
This solves the problem for pushing to running hosts. In order to pull the latest codebase when a new instance fires up, we just stuck some scripts in /etc/rc.local — more on that later.