<img height="1" width="1" src="https://www.facebook.com/tr?id=1076094119157733&amp;ev=PageView &amp;noscript=1">

How to setup various AWS command line tools

Posted by Anirvan Chakraborty on Wed, May 14, 2014

 

On one of my previous blog posts I promised to share with you all the setup guide to install all the various command line tools available from Amzaon. So, in this post I would like to consolidate the setup procedures for the tools that I'm using quite frequently:

  • Elastic Compute Cloud (EC2)
  • Elastic Load Balancer (ELB)
  • Identify and Access Management (IAM)
  • Auto Scaling

If you are reading this post, it means that you are intertested in the various web services that Amazon has to offer for working with their cloud computing platform. Before you start working with the web services, I advice you to configure your development machine with the various command line tools (CLI).

For the purpose of this post I would assume that you are using either a Linux/UNIX machine or an OS X machine. I have left out Windows for the readers imagination!

EC2 command line tool setup

Elastic Compute Cloud from Amazon is a web service that allows you to use resizable compute capacity from Aamzon's cloud computing platform. Download the command line tool for EC2 API from here as a Zip archive. Unzip it and move it to somewhere suitable (e.g. /usr/local).

1. Ensure that Java version 1.6 or later is installed on your system and JAVA_HOME environment variable is set. You can verify your JAVA_HOME setting and the java version installed using the following command:

 $ JAVA_HOME/bin/java -version

2. Set the EC2_HOME and PATH environment variables

 $ export EC2_HOME= 
 $ export PATH=$PATH:$EC2_HOME/bin 

3. Identify yourself to Amazon EC2 using you access keys. Every time you issue a command, you must specify your access keys using the --aws-access-key and --aws-secret-key (or -O and -W) options. Alternatively, you can export the access keys using the following environment variables:

 $ export AWS_ACCESS_KEY=your-aws-access-key
 $ export AWS_SECRET_KEY=your-aws-secret-key 

Doing this would ensure that you don't have to specify the aws-access-key or the aws-secret-key every time when you would want to issue a EC2 CLI command.

4. Verify that EC2 CLI tools has been setup correctly by running the following command:

 $ ec2-describe-regions 

If everything is setup correctly, the output of the above command lists regions and their corresponding service endpoints.

ELB command line tool setup

Elastic Load Balancer is Amazon Web Service that lets you distribute incoming traffic across servers (instances), and constitutes an alternative to servers running software load balancers (SLBs). You can load-balance incoming TCP or HTTP traffic using ELBs.

Download the command line tools for elastic load balancer from here as a Zip archive. Unzip it and move it to somewhere suitable (e.g. /usr/local).

1. Ensure that Java version 1.6 or later is installed on your system and JAVA_HOME environment variable is set.

2. Set the AWS_ELB_HOME environment variable

 $ export AWS_ELB_HOME= 

3. Add the tool's bin directory to your system PATH

 $ export PATH=$PATH:$AWS_ELB_HOME/bin

4. Create a credential file on your system and add your AWS access credentials into it. The contents of the file should look like the following:

AWSAccessKeyId=
AWSSecretKey=

5. Set the credential file permissions

 $ chmod 600 

6. Set the AWS_CREDENTIAL_FILE environment variable to the fully qualified path of the credential file you just created

 $ export AWS_CREDENTIAL_FILE=

7. Set the default region where your instances reside which would be load balanced using the elastic load balancer tool

 $ export AWS_ELB_URL=https://elasticloadbalancing.eu-west-1.amazonaws.com 

8. Verify that the elastic load balancer tool is installed

 $ elb-cmd

If installed correctly you would see a list of all available commands and their description in the elastic load balancer tool.

IAM command line tool setup

The Identity and Access Management web service form Amazon lets you to configure and control access to your AWS services and resources. Using IAM, you can manage AWS users, groups and roles to allow or deny their acces to the AWS resources.

Download the command line tool for identity and access management (IAM) from here as a Zip archive and unzip it to somewhere suitable (e.g. /usr/local).

1. Ensure that Java version 1.6 or later is installed on your system and JAVA_HOME environment variable is set.

2. Set the AWS_IAM_HOME environment variables to the directory where the zip file is extracted to:

 $ export AWS_IAM_HOME=

3. Add the tool's bin directory to your system PATH

$ export PATH=$PATH:$AWS_IAM_HOME/bin 

4. Ensure that AWS_CREDENTIAL_FILE environment variable points to the fully qualified path to your credential file you have created previously.

5. Check that your setup works properly, run the following command:

 $ iam-userlistbypath

The command should simply run with no error output.

Auto scaling command line tool setup

Auto scaling web service from Amazon allows you to scale your computing capacity on Amazon EC2 up or down automatically according to conditions set by you. Using Auto Scaling will also allow you minimize cost while mainitng a performant system running on Amazon EC2.

Download the command line tool for auto scaling from here as a Zip archive. Unzip it and move it to somewhere suitable (e.g. /usr/local).

1. Ensure that Java version 1.6 or later is installed on your system and JAVA_HOME environment variable is set.

2. Set the AWS_AUTO_SCALING_HOME environment variables to the directory where the zip file is extracted to:

 $ export AWS_AUTO_SCALING_HOME=

3. Add the tool's bin directory to your system PATH

 $ export PATH=$PATH:$AWS_AUTO_SCALING_HOME/bin

4. Ensure that AWS_CREDENTIAL_FILE environment variable points to the fully qualified path to your credential file you have created previously.

5. To check that your setup works properly, run the following command:

 $ as-describe-auto-scaling-groups --headers

You should see a header line. If you have auto scaling groups already configured, you will see a description line for each auto scaling group.

Have fun with the various Amazon Web Services from the comfort of your command line! In future posts I intend to show you how to start and stop server instances at your will.

As always, I'm more than happy to hear from you, so feel free to get in touch with me on twitter @anirvan_c or add a comment here.

If you would like to find out more and meet me in person why not drop by my event on the 4th June 2014 'Using DevOps to deliver value early in the software development life-cycle'. Book your place here...

 Need help on your next project?

Recent Posts

Posts by Topic

see all

Subscribe to Email Updates