Wednesday, March 9, 2011

Amazon EC2 Command Line Tool - Step by Step Setup on Ubuntu


Pre-requisites:
  1. Java 5 or above. Either JRE or JDK is acceptable.
  2. Depends on environment variable JAVA_HOME to locate Java runtime.
To setup this environment variable use:

sgoswami@ubuntu:/$ export JAVA_HOME=<PATH>

 <path> : Java Directory which contains subdirectory bin.


Setup Instructions:

sgoswami@ubuntu:~$ export EC2_HOME="/home/sgoswami/ec2-api-tools/"
  • Export environment variables EC2_CERT and EC2_PRIVATE_KEY. As the name suggests they point to the files contain your Amazon account's Private Key and Certificate file. 
e.g.,:

sgoswami@ubuntu:~$ export EC2_CERT="/usr/local/ec2/cert-saasbeta.pem"
sgoswami@ubuntu:~$ export EC2_PRIVATE_KEY="/usr/local/ec2/pk-saasbeta.pem"

If you have followed the instructions correctly you should be able to run the ec2 commands successfully now.

To test it try below:
  1. Navigate to bin folder of ec2. In my case it is: /home/sgoswami/ec2-api-tools/bin
  2. Try the command:
sgoswami@ubuntu:~/ec2-api-tools/bin$ ./ec2-describe-instances

It should list you all the isntances that are running in your Amazon AWS account.

Congratulations you have setup this tool successfully. You can try other commands of this tool. Good Luck.

No comments:

Post a Comment