Tag Archives: aws

Pythonista scripts for EC2

My last post discussed doing web development with an iPad Pro and a VPS, and included Pythonista scripts for automating the creation/deletion of nodes on Linode. Today, I’ll show different versions of these scripts that can be used for starting and stopping EC2 instances.

The scripts assume you have an EBS-backed EC2 instance, which we will start and stop. Unlike Linode and others, EC2 instances of this type do not incur charges when stopped (other than storage), so our scripts will simply start and stop the instance you’ve already created.

To get started, first install boto, a Python library for accessing AWS. The easiest way I’ve found to install it is to run this script, which will install boto in Pythonista, in a folder called boto-module.

Then, in a different folder, save the ec2_start.py script:

Modify it to add EC2 instance ID you want it to start, and the AWS access key you want to use. You’ll be prompted on the first run to enter your secret key, which will be stored in the keychain.

The script will start the instance, and then poll every couple of seconds waiting for the public IP address to be available, which will be copied to the clipboard.

If you want to open another app when the script is completed, pass a URL as a parameter to the script such as workflow://, and that URL will be opened when the script completes. See the prior post for an example of how to do this with the Workflow app.

To stop the instance, use ec2_stop.py:

That’s it – pretty simple, and super convenient for starting and stopping EBS-backed EC2 instances from iOS!

Don on the Amazon outage

An excellent article from the super-smart Don MacAskill, CEO of Smugmug, on how they survived the Amazon Web Services outage and a few tidbits about how their system is designed. One little tidbit:

Once your system seems stable enough, start surprising your Ops and Engineering teams by killing stuff in the middle of the day without warning them. They’ll love you.

You know you’re confident in your system when you throw a dart at a board full of “kill” buttons. :-)

Don was one of the early folks to make a big commitment with AWS – he’s been through a lot with them, and has learned a ton of useful things. Definitely worth a read!