Log In | Register | March 2, 2024


Linux - October 21, 2013

Basic AWS command line setup

Here I’ll be posting the basics of getting and setting up the AWS AMI, API and Cloudwatch tools.

This is my first post on a series of entries I plan to include for several features AWS offers such as auto scaling or setting up a ElasticSearch using AWS.

Things you will need:

  • Linux terminal (duh)
  • Internet access
  • Your AWS access key and secret key
  • Your cert key and privatekey files
  • Your AWS ID
  • java


First let’s download the tools:
$ wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
$ wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip
$ wget http://ec2-downloads.s3.amazonaws.com/cloudwatch-samples/CloudWatchMonitoringScripts-v1.1.0.zip
$ wget http://ec2-downloads.s3.amazonaws.com/AutoScaling-2011-01-01.zip
Unzip each one in the directory of your choosing. I prefer to move them to /opt/ and unzip them there.

$mv ec2* /opt/
$mv Cloud* /opt/
$mv AutoScaling* /opt/
$cd /opt/
$unzip ec2-api-tools.zip
$unzip ec2-ami-tools.zip
$unzip CloudWatchMonitoringScripts-v1.1.0.zip
$unzip AutoScaling-2011-01-01.zip

Since I want one EC2_HOME directory in my PATH for both the API and AMI tools I copied the commands from /bin in the AMI directory to the API one:

$cp /opt/ec2-ami-tools-* /opt/ec2-api-tools-

And the library tools as well:

cp -r /opt/ec2-ami-tools- /opt/ec2-api-tools-

It seems that not following this step will cause the commands for the AMI tools to fail. Probably since they both require to have EC2_HOME specified in the .bashrc file. It just seems easier to copy them over.

Next you will need to add both the tools and Java to your PATH. You can either do this as a one time thing if you only plan to use the command line tools once or edit your local .bashrc file and editing it.

For the temporary method:
$export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-
$export EC2_HOME=/opt/ec2-api-tools-
$export AWS_CLOUDWATCH_HOME=/opt/CloudWatch-
$export AWS_AUTO_SCALING_HOME=/opt/AutoScaling-

Now if you’d like to edit the .bashrc file and make it permanent here is what my .bashrc file looks like:

export EC2_HOME=/opt/ec2-api-tools-
export AWS_CLOUDWATCH_HOME=/opt/CloudWatch-
export AWS_AUTO_SCALING_HOME=/opt/AutoScaling-
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64

Don’t forget to source it after:
$source .bashrc

Test it by running the following:




If you can enter all those without any errors then you’re good to go.

The AMI tools will require a –cert /path/to/certfile, –privatekey /path/to/keyfile/ –user AWS_ID (no dashes)


You CAN copy all the commands from each perspective /bin folder an into one single location and edit the bashrc file accordingly.

Known issue:

running ec2-cmd will not work. It will generate an error: Error: Could not find or load main class com.amazon.aes.webservices.client.cmd. This could be because I didn’t download every AWS tool and obtain every .jar file needed to be in the API’s /lib directory. This won’t prevent the other ec2- commands from working though.

This is a work in progress and if you would like to contribute to this post please leave a comment. If it helps improve this tutorial I’ll update it and of course give credit.

Post By: | FavoriteLoadingAdd to favorites


Tuesday, October 22, 2013

Thanks gabriel for posting this. I was looking around for something like this. It really helped.

Thursday, May 22, 2014

Great article Gabriel

Friday, June 20, 2014

Wonderful beat ! I wish to apprentice at the same time as you
amend your website, how could i subscribe for a blog web site?
The account aided me a appropriate deal. I had been tiny
bit familiar of this your broadcast offered vibrant transparent concept

Leave a Comment

Need Help? Ask a Question

Ask anything you want from how to questions to debug. We're here to help.

You Must Be Logged In To Post A Question.

Log In or Register