A company I've been working with hosts some of their applications on EC2. As someone who has spent years working with Linux and Unix servers from the command line, I find the EC2 web console pretty frustrating. Here's how I set up the EC2 API tools on my MacBook Pro so I can manage instances from the terminal.
mkdir ~/.ec2
cd ~/Downloads
curl -O -L "http://www.amazon.com/gp/redirect.html/ref=aws_rc_ec2tools?location=http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip&token=A80325AA4DAB186C80828ED5138633E3F49160D9"
unzip ec2-api-tools.zip*
cd ec2-api-tools
mv bin lib ~/.ec2/
echo 'export EC2_HOME=~/.ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`
export EC2_CERT=`ls $EC2_HOME/cert-*.pem`
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/
# I use eu-west-1 - you may want to change this
EC2_REGION="eu-west-1"
export EC2_URL="https://${EC2_REGION}.ec2.amazonaws.com/"
export EC2_KEYPAIR_NAME="aws-`whoami`"' > ~/.ec2/env
echo '[ -f ~/.ec2/env ] && . ~/.ec2/env' >> ~/.profile
ec2-add-keypair aws-`whoami` > ~/.ec2/aws-`whoami`
chmod 0600 ~/.ec2/aws-`whoami`
Next, download the X.509 private key and certificate from the Security Identifiers page of your AWS account and save them to ~/.ec2/. Leave the filenames as-is with the big messy jumble of characters — the setup script uses a glob pattern to find them.
That should be everything. To verify it's working, try listing all the Amazon-owned machine images:
ec2-describe-images -o amazon
You should see a long list that looks something like this:
IMAGE ami-13042f67 amazon/fedora-8-i386-v1.14-std amazon available public i386 machine aki-61022915 ari-63022917 ebs
BLOCKDEVICEMAPPING /dev/sda1 snap-34739d5d 15
IMAGE ami-1d042f69 amazon/fedora-8-x86_64-v1.14-std amazon available public x86_64 machine aki-6d022919 ari-37022943 ebs
BLOCKDEVICEMAPPING /dev/sda1 snap-08739d61 15
All the EC2 commands are prefixed with ec2-. To see them all:
ls ~/.ec2/bin/ec2-*
If you see deprecation notices from Xalan, don't worry about it — everything still works fine:
[Deprecated] Xalan: org.apache.xml.res.XMLErrorResources_en_US