Sumo: One-off EC2 Instance Launching

cloud ec2 chef sumo redis

Fri Aug 28 14:01:33 -0700 2009

One of the things I love about cloud computing is being able to quickly spin up instances for testing and experimentation. Lately I’ve started to become annoyed at the six or seven manual steps necessary to launch and connect to an instance on EC2 using the standard ec2-* command line tools. So I created a small tool to fire up a one-off instance, which I’m calling Sumo.

Witness:

$ sumo launch
---> Launching instance...    i-4f809c26 (1.5s)
---> Acquiring hostname...    ec2-67-202-17-178.compute-1.amazonaws.com (26.7s)

Logging you in via ssh.  Type 'exit' or Ctrl-D to return to your local system.
------------------------------------------------------------------------------
Linux domU-12-31-39-04-31-37 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686
...
root@domU-12-31-39-04-31-37:~#

One command gets you a shell into a newly provisioned instance. Saves you the rigamarole of ec2-launch-instances / describe-instances / wait for hostname / cut-and-paste hostname / ssh command.

A bit more experimental, but Works On My Machine:

$ sumo launch redis
---> Launch instance...       i-b96c73d0 (1.3s)
---> Acquire hostname...      ec2-75-101-191-220.compute-1.amazonaws.com (36.1s)
---> Wait for ssh...          done (9.0s)
---> Bootstrap chef...        done (61.3s)
---> Setup redis...           done (11.9s)
---> Opening firewall...      ports 6379 (5.2s)
 
Your instance is exporting the following resources:
  Redis: redis://:8452cdd98f428c972f08@ec2-75-101-191-220.compute-1.amazonaws.com:6379/0

One command gets you a Redis endpoint that you can plug into export REDIS_URL= to run a blog on Redis. Not bad. (I’m a Chef newbie, so my Redis recipe probably sucks, but works for me.) Other recipes could be added, and then you can specify multiple roles on the same machine if you like:

$ sumo launch redis,couchdb
[...]
Your instance is exporting the following resources:
  CouchDB: http://ec2-75-101-191-220.compute-1.amazonaws.com:5984/
  Redis: redis://:8452cdd98f428c972f08@ec2-75-101-191-220.compute-1.amazonaws.com:6379/0