Schedule start/stop on AWS instances

In this post we will schedule starting and stopping AWS instances based on tags using Python (but you can do the same with any aws-sdk of your choice).

First install aws needed packages¬†(i’m using a debian machine) :

Then configure a new profile (if you don’t have one already configured) :

In order to schedule stop and start for our ec2 instances, we need to tag them for example : stop-start tag, then specify stop and start hours like this : 08-19, this mean start instance at 08 AM and stop it at 07 PM.

You can cron this script to run every hour for example and check if ther’s an action to perform. This script use a simple configuratin file :