Setting Up The Amazon EC2 Command Line Interface Tools On Windows
Setting Up The Amazon EC2 Command Line Interface Tools On Windows
on Windows
The Amazon EC2 command line interface tools (also called the CLI tools) wrap the Amazon
EC2 API actions. These tools are written in Java and include shell scripts for both Windows and
Linux/UNIX/Mac OSX.
Note
Alternatively, you can use the AWS Command Line Interface (AWS CLI), which provides
commands for a broad set of AWS products, including Amazon EC2. To get started with the
AWS CLI, see the AWS Command Line Interface User Guide. For more information about the
AWS CLI commands for Amazon EC2, see ec2 in the AWS Command Line Interface Reference.
Before you can use the Amazon EC2 CLI tools, you need to download them and configure them
to use your AWS account. You can set up the tools on your own computer or on an Amazon EC2
instance.
Complete the following tasks to set up your Amazon EC2 environment:
1.
2.
3.
4.
5.
6.
7.
Note
These instructions are written for a Windows 7 client. What you need to do to complete some
tasks may vary if you're using a different version of Windows.
(Optional) You can verify that the CLI tools package has not been altered or corrupted after
publication. For more information about authenticating the download before unzipping the file,
see (Optional) Verify the Signature of the CLI Tools Download.
g. Click OK.
3. Open a new Command Prompt window and verify your JAVA_HOME setting using this
command:
C:\> "%JAVA_HOME%"\bin\java -version
If you've set the environment variable correctly, the output looks something like this:
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)
Otherwise, check the setting of JAVA_HOME, fix any errors, open a new Command Prompt
window, and try the command again.
4. Add the bin folder that contains the Java executable to your path before other versions of
Java.
a. Return to the Environment Variables window. In User variables, select Path,
and then click Edit. (If this environment variable doesn't exist, create it.)
b. In Variable values, before any other versions of Java, add
;%JAVA_HOME%\bin. Then click OK.
5. Open a new Command Prompt window and verify your update to the Path environment
variable using this command.
C:\> java -version
You should see the same output as before. Otherwise, check the setting of Path, fix any
errors, open a new Command Prompt window, and try the command again.
Task 3: Set the EC2_HOME Environment Variable and Update the Path
Environment Variable
The Amazon EC2 CLI tools read the EC2_HOME environment variable to locate supporting
libraries. You'll need to set this environment variable to the path where you unzipped the CLI
tools. This folder is named ec2-api-tools-w.x.y.z (where w, x, y, and z are components of the
version number). It contains subdirectories named bin and lib. You'll then need to update the
Path environment variable to include the bin subdirectory.
To set the EC2_HOME variable and update the Path variable on your computer or instance
1. Set EC2_HOME to the path of the folder into which you unzipped the CLI tools.
Important
These steps don't update the environment variables in your current Command Prompt
windows. The Command Prompt windows that you open after you complete these steps
will contain the updates. This is why it's necessary for you to open a new Command
Prompt window to verify that your environment is set up properly.
a. Click Start, right-click Computer, and then click Properties.
b.
c.
d.
e.
f.
If you've set the environment variable correctly, you'll see output for the folder listing. If
you get a File Not Found error, check the setting of EC2_HOME, fix any errors, open a
new Command Prompt window, and try the command again.
3. Update the Path environment variable by adding the bin folder for the tools.
a. Return to the Environment Variables window. In User variables, select Path,
and then click Edit.
b. In Variable values, add ;%EC2_HOME%\bin, and then click OK.
The Amazon EC2 CLI tools use your access keys to identify you, and to sign requests on your
behalf. There are two types of access keys: access key IDs (for example,
AKIAIOSFODNN7EXAMPLE) and secret access keys (for example,
wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY). You should have stored your access
keys in a safe place when you received them. Although you can retrieve your access key ID from
the Your Security Credentials page or the IAM console (if you are an IAM user), you can't
retrieve your secret access key. Therefore, if you can't find your secret access key, you'll need to
create or request new access keys before you can use the CLI tools.
Note
The EC2 CLI tools use your access keys as well as a time stamp to sign your requests. Ensure
that your computer's date and time are set correctly. If they are not, the date in the signature may
not match the date of the request, and AWS rejects the request. For more information about
setting the time on your Windows instance, see Setting the Time for a Windows Instance in the
Amazon EC2 User Guide for Microsoft Windows Instances.
Every time you issue a command, you must specify your access keys using the --aws-accesskey and --aws-secret-key (or -O and -W) options. Alternatively, you might find it easier to
store your access keys using the following environment variables:
AWS_ACCESS_KEYYour
access key ID
AWS_SECRET_KEYYour secret access key
If these environment variables are set properly, their values serve as the default values for these
required options, so you can omit them from the command line.
The following procedure describes how to create environment variables that specify your access
keys.
To set up your environment variables on your computer or instance
1. Click Start, right-click Computer, and then click Properties.
2.
3.
4.
5.
6.
If your environment variables are set correctly, you'll see output that looks something like this.
REGION
REGION
REGION
REGION
REGION
REGION
REGION
us-east-1
eu-west-1
sa-east-1
ap-northeast-1
us-west-2
us-west-1
ap-southeast-1
ec2.us-east-1.amazonaws.com
ec2.eu-west-1.amazonaws.com
ec2.sa-east-1.amazonaws.com
ec2.ap-northeast-1.amazonaws.com
ec2.us-west-2.amazonaws.com
ec2.us-west-1.amazonaws.com
ec2.ap-southeast-1.amazonaws.com
If you get an error that this command is not recognized as an internal or external command,
check the setting of the EC2_HOME and Path environment variables, fix any errors, open a new
Command Prompt window, and try the command again.
If you get an error that required option -O is missing, check the setting of AWS_ACCESS_KEY, fix
any errors, open a new Command Prompt window, and try the command again.
If you get an error that required option -W is missing, check the setting of AWS_SECRET_KEY, fix
any errors, open a new Command Prompt window, and try the command again.
If you get a Client.AuthFailure error, check that you've entered your AWS_ACCESS_KEY and
AWS_SECRET_KEY correctly, and check that the date and time are set correctly on your computer.
This section describes how to specify a different region by changing the service endpoint URL.
To specify a different region on your computer or instance
1. To view available regions, see Regions and Endpoints in the Amazon Web Services
General Reference.
2. To change the service endpoint, set the EC2_URL environment variable.
The following example sets EC2_URL.
a. Click Start, right-click Computer, and then click Properties.
b. Click Advanced system settings.
c.
d.
e.
f.
Description
https.proxyHost
https.proxyPort
http.proxyHost
http.proxyPort
http.proxyDomain
Property
Description
http.proxyWorkstation
http.proxyUser
http.proxyPass
http.nonProxyHosts