How to launch an AWS instance via cron.03 Nov 2014
I'm not a big python developer, but I'm able to read documentations. There are several expensive services on the worl wide web, that allows you to start AWS instances using a specific schedule. Some free services do not allow to bring up instances of expensive types like "c3.xlarge".
For me, that is all too much, because I want to start a prepared AWS-instance once in a week. I created a solution, that uses an available Python library called boto and a common cron on a running linux machine (or a tiny RaspberryPi).
Note: This script does not create an Instance out of AMI-images, but you are able to achieve that as well.
How to setup it?
You need to generate an AWS-service key -link is a documentation about that-, which you need to keep it as secret as your passwords.
Install the python library python-boto.
Create the following script:
region-abcto region you instances are located.
secretshould be replaced with the API credentials you generated above and the
i-4711you see in your overview on the EC2 list.
- Put the script to the crontab like:
1 3 * * 1 python ~/bin/start_aws_instance.py
I use this as a tiny, cheap solution to quickly fire and forget one instance. The script doesn't fail, if the instance is already up and running. If you use this way to start the instance, you should add a shutdown option in your running AWS-instance. I use a build script fired up right after instance is finished with booting. After the complete script is processed, a norma
shutdown -h now is initiated.
I don't recommend to use this in a large scale or buisiness critical solution, but sometimes you need a "quick win".