Nice and Simple AWS EC2 Start Stop Script – Python

Here is a nice and simple AWS EC2 start stop script written in Python and run from the command line. The parameters are just start|stop and the name of your instance.

I’ve written it so it uses the tag Name instead of requiring the specific instance ID. The script’s ideal usage may be to schedule the start|stop of an instance at particular times of the day. So you might have a test server you use during 10AM and 3PM Monday to Friday. With this script you could setup a scheduled task on a remote computer to start|stop the instance based on your schedule, saving you money!

Prerequisites

In order to run this script you’ll need to have Python and the AWS library Boto installed on your computer. Remember this can be any computer with an internet connection (ideally not the EC2 instance you plan on stopping/starting). The script will run on Linux and Windows.

I’ve previously written guides on installing Python and Boto into Linux environments. If you use Windows, you will find many guides stepping you through this process.
Continue reading…