A Quick Way to Manage Multiple Amazon AWS Accounts

I’m often switching between different Amazon AWS accounts. So to speed things along I’ve set up some simple scripts to easily switch between accounts while at the command line

On Linux (aws_setup):

export EC2_URL=https://eu-west-1.ec2.amazonaws.com
export EC2_CERT=/home/john/cert-12345678901234567890123456789012.pem
export EC2_PRIVATE_KEY=/home/john/pk-12345678901234567890123456789012.pem</code>

Once saved, run chmod +x aws_setup
On Windows (aws_setup.cmd):

<code>SET EC2_URL=https://eu-west-1.ec2.amazonaws.com
SET EC2_CERT=C:\Users\John\cert-12345678901234567890123456789012.pem
SET EC2_PRIVATE_KEY=C:\Users\John\pk-12345678901234567890123456789012.pem</code>

Save as many files with the paths to your various AWS key pairs, and simply run the script from within a terminal before using the ec2 tools.

NOTE, when you run the scripts on Linux (and I guess Macs), add an extra dot before you run it. This will allow the environment variable to persist when the script ends.

<code>. ./aws_setup</code>

Commands to get started with Amazon EC2

Here are some simple commands to get you started with using Amazon EC2:

Displays your account’s AMIs that are on Amazon

ec2run ami-XXXXXXXX
This launches your Amazon EC2 instance. Use your own or one of Amazon’s AMI IDs

Describes your running instances with AMI and instance IDs

Lists your account’s volumes and their status

ec2attvol vol-XXXXXXXX -i i-XXXXXXXX -d xvdf
Attaches an Elastic Block Storage device to your running instance

ec2detvol i-XXXXXXXX
Detaches the storage volume from an instance (use -f to force)

ec2stop i-XXXXXXXX
Stops a running instance so that you can perform maintenance on it

ec2minatt i-XXXXXXXX
Modifies an instance attribute such as the instance type

ec2start i-XXXXXXXX
Resumes your stopped instance

ec2kill i-XXXXXXXX
Terminates your running instance

Twitter Weekly Updates for 2010-10-10

  • Can't sleep? Use Twitter! http://bbc.in/d45LiP #
  • A great article that I've just read: A survival guide to building a successful open source project http://bit.ly/aOpUgY #
  • Interesting article. The Japanese have fewer 'social net' friends, and the use social networks in a national crisis http://bbc.in/dhNeKU #
  • Finally! It's about time we had self-driving cars. If they could just make them fly… http://bbc.in/d4ouMC #

Powered by Twitter Tools

Twitter Weekly Updates for 2010-10-03

  • PHP Tip: Find out what user account your webserver uses with <?php echo(exec("whoami")); ?> #
  • http://twitpic.com/2tx3w9 – Yet another fab deal. Don't miss this one! #shoppingnodeals #
  • http://twitpic.com/2txfod – Don't forget it's the International Kite Festival in Margate this weekend. #
  • Awesome tips for development: 9 Ways to Instantly Code Faster: http://bit.ly/cYJsNx #
  • When I read WordPress source code, I sometimes want to cry uncontrollably. #

Powered by Twitter Tools