I use the amazon command line tools a lot, its often a
quicker way to accomplish things quickly versus the AWS web interface, though the AWS web interface has gotten a lot
better over the past few years)
In this guide I am going to show how to set up the command
lines tools using Ubuntu, I have another (slightly different guide for Cygwin)
Ubuntu AWS setup
First you need a place to put all the keys you will use from
AWS. These keys will be referenced by
your program
From the home directory create a “.ec2” folder .
> mkdir ~/.ec2
|
Get the keys setup
Now get some keys to put in there.
Open up http://aws.amazon.com/
Click on My Account/Console -> Security Credentials
Sign in using your
username/password
Scroll down to the “Access Credentials” and select the X.509
Certificates and click Create a new Certificate.
Click on Download Private Key File and save the file to the .ec2 folder
Then click on the “Download X.509 Certificate” button and save the certificate to the .ec2 folder
Now log into AWS Management Console
Open up http://aws.amazon.com [1]
Click on My Account/ConsoleàAWS Management Console
Click on EC2
Click on Key Pairs
under the “Network & Security”
Click on Create Key Pair
Give it a name and
click create.
A prompt to save
this file will appear, save it to the .ec2 directory (in my case I am using win-7 then using
Cygwin to scp it to my Ubuntu server)
Install Command line tools
Open http://aws.amazon.com/developertools [2]
And do a quick search for command-line.
Here is a EC2 command line tool. You will see that there are different command line tools for different AWS services (EC2, RDS, etc) For now just get the EC2 command line tool
This is the main EC2 command line API tool to look for.
It is located at
Click on Download the Amazon EC2 API tools from Amazon S3
Create a folder in your home directory named ec2-api-tools
> cd
> mkdir
ec2-api-tools
|
Now unzip the downloaded command line tools into this
directory
> cd
~/ec2-api-tools
> unzip ~/ec2-api-tools.zip
> mv ec2-api-tools-1.6.4/* .
> rm -r ec2-api-tools-1.6.4
> ls -alh
|
This should put a bin and a lib folder
JAVA_HOME set
Java must be installed and JAVA_HOME set.
First to install JAVA 1.7 on Ubuntu…
Go to
And click on Download
Click on the “Accept License” Button then click on the
version you want to download.
In my case I chose jre-7u9-linux-x64.tar.gz
It used to be that you could then copy the link and use a wget
from the command line to get the file, but no longer. So manually download
the version you want.
Untar it
> tar
-xvf jre-7-linux-i586.tar.gz
|
Move JRE folder to /usr/lib
> sudo
mkdir /usr/lib/jvm
> sudo
mv jre1.7.0_09 /usr/lib/jvm/jre1.7.0_09
|
Make a link
> sudo
ln -fs /usr/lib/jvm/jre1.7.0_09/bin/java /usr/bin/java
|
Now if you run
> java
-version
|
You should get the correct response
Now add JAVA_HOME to .bashrc
export JAVA_HOME=/usr/lib/jvm/jre1.7.0_09
|
Now add the following to the end of the .bashrc file for ec2
keys
export EC2_HOME=$HOME/ec2-api-tools
export EC2_PRIVATE_KEY=$HOME/.ec2/pk-XXXXX.pem
export EC2_CERT=$HOME/.ec2/cert-XXXXX.pem
export PATH=$PATH:$EC2_HOME/bin
|
If your "default" region is not going to be the
east coast you can set your default region in your bash file
EC2_URL=https://ec2.us-west-2.amazon.com
|
This would be for the Oregon (us-west-2) region
Now run source
> source
.bashrc
|
Now attempt to run this command
> ec2-describe-keypairs
|
If you want to check a different region than your default
region use the --region flag
> ec2-describe-keypairs
--region us-west-2
|
This will list your keypairs
(I whited my actual numbers out J )
References
[1] Amazon Web
Services
Visited 10/2012
[2] AWS Developer Tools
Visited 10/2012
No comments:
Post a Comment