|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
This guide is based on Windows 7, Service Pack 1. Other versions of Windows may require adjustments to these instructions.
The CloudFormation CLI tools depend on the Java runtime (JRE), which is not installed by default on Windows 7. You must have version 5 or later installed on your system. You can use either the 32-bit or 64-bit version.
To check your Java version, open a Command Prompt and change your directory to the the JRE bin folder. This is typically C:\Program Files (x86)\Java\jre#\bin (32-bit) or C:\Program Files\Java\jre#\bin (64-bit), where # represents the version number. Then type:
> java -version
The return value is in the form
major_version is less than 5, or the command returns an
error, you must update your JRE. To download the latest version of Java, go to http://java.com/download.
Note your Java version number and whether it is 32-bit or 64-bit. Make sure to use the same version consistently throughout this procedure.
Before setting anything up on your system, you'll need to download the AWS CloudFormation CLI tools. To download them, go to the AWS CloudFormation Command Line Tools page, and then click Download.
The downloaded file is named
Once you've downloaded the AWS CloudFormation CLI archive, unzip it by following these steps:
Open Windows Explorer and navigate to your
Right-click the .zip file and click Extract All on the context menu.
The extracted directory will be AWSCloudFormation-cli\AWSCloudFormation-#.#.#, where #.#.# represents the current version number (currently 1.0.12).
You can install the CLI Tools in any directory you choose, though for simplicity, it's
good to install them in a location within your home directory. It is identified on Windows
USERPROFILE environment variable, and is usually
name is your
Windows user name. Once you begin using CloudFormation, you'll likely want to install
command-line tools for other AWS services, so we'll install the CloudFormation CLI tools
within a directory designed to house all of these toolsets, called
You can name the directory anything you want. If you do this, however, remember to consistently
substitute the location you've chosen for the
awstools directory we'll use throughout
To prepare the install location
Open a Terminal window by doing one of the following:
Open the Windows Start menu, click All Programs, then Accessories, and finally Command Prompt.
Open the Windows Start menu and type
Command in the Search
Programs and Files text box. Click the Command Prompt
In your command prompt, create the installation directory by typing:
> mkdir %USERPROFILE%\awstools
This will create a directory (if it doesn't already exist) called "awstools" in your home directory.
You can use
%USERPROFILE%\awstools as the base directory for all
AWS toolsets you want to install. Here, we'll concern ourselves only with installing the
CloudFormation CLI tools.mo
To install the CLI tools
Change your working directory to %USERPROFILE%\awstools. You can do this on the command-line with:
> cd %USERPROFILE%\awstools
Move the unzipped AWSCloudFormation-#.#.# directory to the install location, by typing:
Downloads represents your downloads folder, which
depends on your browser. Typical values are C:\Downloads or %USERPROFILE%\Downloads.
Replace all instances of # with the appropriate version number for your installation.
Change your working directory to the install directory, which you can do on the command line by typing
Replace all instances of # with the appropriate version number for your installation. In this directory, you will find a file named
credential-file-path.template. This file can be used to supply your
AWS credentials to the tools automatically so you won't need to pass these credentials to
the tools on the command-line every time you run them.
Adding your credentials to this file can save you time, but can also present a security risk if your system is used by others, since your security key will be stored as plain text on your system.
If you don't have your AWS credentials handy, you can view them by logging into the AWS console and selecting Security Credentials from the My Account / Console menu at the top of the screen. On the page, click Access Credentials to see your access key under the Access Key ID heading. Your secret key can also be viewed here by clicking the show button under the Secret Access Key heading.
Do not share your secret access key with anyone! With your secret access key, anyone would be able to use AWS services and charge usage fees to your account.
If you don't want to keep your credentials in a file on your system, you can skip the
next procedure, and instead pass your credentials directly to the AWS CloudFormation CLI
tools with the
--I ACCESSKEY and
SECRETKEY arguments, replacing ACCESSKEY and
SECRETKEY with your AWS credentials. You will need to do this every
time you use the CLI tools.
To add your AWS credentials to the AWS credential file
Go to the AWS CloudFormation CLI tools install directory from the command-line, using:
> cd %USERPROFILE%\awstools\AWSCloudFormation-
This assumes that you installed the CLI tools into
%USERPROFILE%\awstools. If you did not, replace the location in
the example above with the pathname to the location where you installed the CLI
tools. Replace all instances of # with the appropriate version number for your installation.
Copy or rename the credential-file-path.template file to a filename of your choosing (you can even use credential-file-path.template as the filename, but I prefer something that better describes its purpose). For the purposes of this article, we'll use "myAWSCredentials.txt":
> copy credential-file-path.template myAWSCredentials.txt
Edit the file with your favorite text editor, enter your AWS credentials, then save and close the file. The file should contain two lines in it, like this:
Note: These are example values, and won't work for an actual connection to AWS. Instead, use your own AWS security credentials here.
Finally, you'll need to add a few environment variables to your system. Since you'll be
using the CloudFormation CLI tools from the command-line, you can simply add these to your
To add the CloudFormation CLI tools environment variables:
%USERPROFILE%\profile.bat in your favorite editor. If it
does not exist yet, create it.
%USERPROFILE%\profile.bat, add the following lines:
REM CloudFormation CLI tools setup set JAVA_HOME=C:\Program Files (x86)\Java\jre
#.#.#set AWS_CREDENTIAL_FILE=%AWS_CLOUDFORMATION_HOME%\myAWSCredentials.txt set PATH=%PATH%;%AWS_CLOUDFORMATION_HOME%\bin
Replace all instances of # with the appropriate version number for your installation..
This example assumes that you installed the CLI tools into
%USERPROFILE%\awstools. If you did not, replace
$USERPROFILE with the pathname to the location where you installed the CLI
This example uses the 32-bit version of the JRE. To use the 64-bit version, set JAVA_HOME to "C:\Program Files\Java\jre#, where # represents the Java version number (usually 6 or 7).
If you did not add your AWS access keys to an external file (such as the
myAWSCredentials.txt file specified above), you should
not assign the
environment variable. Instead, remove or comment-out that line.
Create a shortcut that starts a command-line prompt and then loads your batchfile. To do this:
Right-click your Windows desktop and choose New, then Shortcut in the context menu.
In the Create Shortcut dialog, type
%USERPROFILE%\profile.bat and click
Choose a name for your shortcut, such as
Prompt, and click Finish to create the
shortcut on your Windows desktop.
To load your environment variables, quit your current command prompt session and then restart it by using the shortcut you just created.
Test your installation by running cfn-cmd:
This will list all of the available CloudFormation CLI tools, their usage, and the
available options for
cfn-cmd itself (there are two options: