Using the Amazon EC2 Command Line Tools and API

There are three ways to interact with Amazon EC2:

  1. Web based AWS Management Console
  2. Command line tools
  3. An API for programmers

The Web based console is very easy to use and you can (and should!) do a lot with it. There are times, however, where what you want to do is beyond what is currently possible with AWS console. Or you may need to do something that involves managing multiple instances in an automatic, repeatable and consistent manner. In these cases you need to use the other options.

The command line tools and API allow developers and operations people to program or script robust solutions that can leverage the IaaS that Amazon provides. These developer and operations roles (sometimes referred to collectively as “DevOps“) may be filled by technical folks internal to an organization or may be from third parties. Indeed there are numerous providers of value added services for managing and configuring EC2 environments. Typically these solutions are often custom applications which involve, among other things, calling into the API.

To get started using the command line tools you need to take a look at the documentation that Amazon provides. It is not necessary, in my opinion, to read it start to finish. You must, however, be at least somewhat familiar with what the commands are.

Then, you need a machine with the tools installed. One option is to download and install the tools on your own machine. Another option is to use one of the pre-configured Amazon Linux AMIs Amazon provides with the tools already installed.

In either case you will ultimately need to roll up your sleeves and get busy with the Windows or Linux command prompt. For one thing you will need to set up your machine so that it can securely access your account. This involves downloading a certificate and private key file and setting some environment variables to establish your identify and the location of the Java runtime. You also need to set your path to include tool script location.

Amazon provides both “API Tools” and “AMI Tools”. The API tools bring the API functionality to the command line. Essentially the commands are just lightweight wrappers that call into the API. They are implemented as cmd files in Windows or shell scripts on Linux machines. The AMI tools provide utilities for creating, bundling and uploading AMI’s. Unfortunately I’ve never been able to get the AMI tools to completely work on Windows.

To get started using the API you will need to download and install the appropriate SDK for your particular programming language. There are SDKs and/or libraries for Java, PHP, Python, Ruby and .NET. If you use Eclipse as your development environment you can also download and install the AWS Toolkit for Eclipse. Oh, by the way, you also do need to have a look at the documentation!

These screencasts demonstrate using the command line tools and the API.

If you want to learn more about how you can bring the power of the cloud to your organization please consider attending Learning Tree International’s Introduction to Cloud Computing course coming soon to a venue (hopefully) near you! Or, if you’d prefer, attend from the comfort of your own location via Learning Tree’s AnyWare system.

Kevin Kell

As cloud computing continues to make information technology headlines, vendors are aggressively promoting the many benefits it can provide organizations.  Our White Paper, Cloud Computing Promises: Fact of Fiction, addresses the claims and questions that are often raised in relation to cloud computing and provides a clear view of what the cloud can—and can’t—deliver in reality.

Type to search

Do you mean "" ?

Sorry, no results were found for your query.

Please check your spelling and try your search again.