Nightly shutdown tool for AWS EC2 cost-control
When you've got lots of people working on the same AWS capacity, it's easy for somebody to forget to spin down their instances when they're not in use. This tool stops, but does not terminate, any instances in EC2 whose instance-id is not in the whitelist in nightly-shutdown.yml.
How to use it
Run the following commands as root.
Ensure boto is installed.
yum install -y python-pip pip install boto
Clone this repo
git clone https://github.com/jason-callaway/nightly-shutdown
Put the nightly-shutdown.yml config file in
/etc. Don't forget to change mode and ownership to root-only to protect your access and secret keys.
cp nightly-shutdown/nightly-shutdown.yml /etc chown root:root /etc/nightly-shutdown.yml chmod 600 /etc/nightly-shutdown.yml
Add your access and secret keys to the config file. White list any instances you'd like to opt-out of the nightly shutdown.
region: us-east-1 access_key: eggseggseggseggs secret_key: spamspamspamspam whitelist: - i-abcdefgh - i-ijklmnop
Copy the utility to cron.daily.
cp nightly-shutdown/nightly-shutdown.py /etc/cron.daily/nightly-shutdown chmod 755 /etc/cron.daily/nightly-shutdown