The process that I followed to install the command line Amazon EC2 API tools on a MacBook Pro running Mac OS X Leopard.

Install the tools

Install the tools as per the EC2 API Setting Up the Tools. (I would recommend /usr/local as the install location).

Don't forget to setup your Java Home

export \ 
JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"

Security Credentials

Create the ~/.ec2 directory and check / change it's permissions.

[hgilmour@hgilmour-mac:~]$ mkdir .ec2       
[hgilmour@hgilmour-mac:~]$ ll .ec2
total 0
drwxr-xr-x   2 hgilmour  staff    68 Sep 18 11:57 .
drwxr-xr-x+ 84 hgilmour  staff  2856 Sep 18 11:57 ..
[hgilmour@hgilmour-mac:~]$ chmod 700 .ec2
[hgilmour@hgilmour-mac:~]$ ll .ec2
total 0
drwx------   2 hgilmour  staff    68 Sep 18 11:57 .
drwxr-xr-x+ 84 hgilmour  staff  2856 Sep 18 11:57 ..

Generate your private key and X.509 certificate and download them to ~/.ec2 as described in the latest User Guide under Using Credentials, then click on How to Create an X.509 Certificate and Private Key.

Add these files to your environmental variables

Substitute $YOUR_VALUE for your file's value.

export EC2_PRIVATE_KEY=~/.ec2/pk-$YOUR_VALUE.pem 
export EC2_CERT=~/.ec2/cert-$YOUR_VALUE.pem

Check the environment

Use grep or ack if you have it installed.

[hgilmour@hgilmour-mac:~/.ec2]$ . ~/.zshenv
[hgilmour@hgilmour-mac:~/.ec2]$ env | ack EC2
EC2_HOME=/usr/local/amazon/ec2
EC2_AMITOOL_HOME=/usr/local/amazon/ec2
EC2_PRIVATE_KEY=/Users/hgilmour/.ec2/pk-$YOUR_VALUE.pem
EC2_CERT=/Users/hgilmour/.ec2/cert-$YOUR_VALUE.pem

View available regions

[hgilmour@hgilmour-mac:~]$ ec2-describe-regions
REGION  eu-west-1   eu-west-1.ec2.amazonaws.com
REGION  us-east-1   us-east-1.ec2.amazonaws.com

Change the reqion

To eu-west-1 by adding the environmental variable EC2_URL:

export EC2_URL=https://eu-west-1.ec2.amazonaws.com/

Check the environment

[hgilmour@hgilmour-mac:~]$ . ./.zshenv; env | ack EC2
EC2_HOME=/usr/local/amazon/ec2
EC2_AMITOOL_HOME=/usr/local/amazon/ec2
EC2_PRIVATE_KEY=/Users/hgilmour/.ec2/pk-$YOUR_VALUE.pem
EC2_CERT=/Users/hgilmour/.ec2/cert-$YOUR_VALUE.pem
EC2_URL=https://eu-west-1.ec2.amazonaws.com

You're Done !

Useful links

Amazon Elastic Compute Cloud (EC2) Documentation

API Command Line Tools Reference

Filed under: tools, infrastructure

comments

There are no comments.