In Amazon EC2, how do I make it run a python script when I “clone” that instance?
Solution 1:
Since the OP posted his original question, there's been a lot of work done with Ubuntu cloud-init. If you're using an Ubuntu server on for EC2 (we use it almost exclusively in production), it's quite easy to specify a Python script to be executed when the instance is created.
Cloud-init supports mulit-part input, so you can insert both an upstart job and have it run a user-data script.
https://help.ubuntu.com/community/CloudInit