|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
This guide is based on Ubuntu Linux 11.10. Specific steps may vary for other versions of Linux, but these instructions should apply to most modern Linux distributions.
The AWS AWS CloudFormation CLI requires the Java Runtime Environment (JRE) 1.5 or later. Depending on your Linux distribution, the runtime may already be installed. To see what version of Java is installed on your computer, open a terminal window. At the command prompt, type the following, and then press Enter:
$ java -version
If this command returns an error or reports a Java version earlier than 1.5, or returns an error, you must update your JRE to at least version 1.5 or install the runtime if it is not already installed. For information about installing the JRE, go to the Java website.
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
You can install the AWS CloudFormation CLI tools in any directory you choose. For simplicity, though, it's a good idea to
install them in a location within your home directory (typically /home/name, where
name is your Linux user name). Once you begin using AWS CloudFormation, you'll probably want to install
command-line tools for other AWS services, so we'll install the AWS CloudFormation CLI tools within a directory
designed to house all of these toolsets, called
A directory with an initial period (.) will be hidden by default to the file manager and to the
ls command. We hide the directory so that it won't clutter the view of your home directory. If you
don't want it hidden, name it simply
awstools or anything else you choose. It won't affect how
the tools work as long as you consistently substitute your chosen location for the
directory that we'll use throughout this guide.
To prepare the installation directory
Open a terminal window. To open a terminal window on Ubuntu Linux:
Open the Ubuntu menu (called Dash home).
In the search box, type
Click Terminal to open the terminal window.
Create the installation directory. At the command prompt, type the following, and then press Enter:
$ mkdir ~/.awstools
This command will create a hidden directory (if it doesn't already exist) called
.awstools in your home directory. You can use
~/.awstools as the
base directory for all AWS toolsets that you want to install. For now, we'll just concern ourselves with
installing the AWS CloudFormation CLI tools.
To install the CLI tools
Change your working directory to
~/.awstools. At the command prompt, type the following, and then press Enter:
$ cd ~/.awstools
AWSCloudFormation-cli.zip, which you downloaded earlier, in the
installation directory. At the command prompt, type the following, and then press Enter:
$ unzip ~/Downloads/AWSCloudFormation-cli.zip
This command will create a subdirectory called
AWSCloudFormation-#.#.#, where each #
represents part of the version number.
(Optional) Link to the installation directory. At the command prompt, type the following, replacing #.#.# with the version number of the downloaded tools, and then press Enter.
$ ln -s AWSCloudFormation-
For example, to link to version 1.0.11 of the tools, you would type:
$ ln -s AWSCloudFormation-1.0.11 cfn
Linking to the installation directory makes it easy to switch to a new version of the tools. It also gives you the ability to easily switch to another version by simply overwriting the link to point to the installation directory of the version you want to use.
Within the installation directory, you will find a file named
credential-file-path.template. You can use this file to automatically supply your AWS
credentials to the AWS CloudFormation CLI instead of supplying them with each command you issue.
Adding your credentials to this file can save you time, but it can also present a security risk if your system is used by others, because the file stores your access key ID and secret key as plain text.
To view your AWS access credentials
Go to the Amazon Web Services website at http://aws.amazon.com.
Click My Account/Console, and then click Security Credentials.
Under Your Account, click Security Credentials.
In the spaces provided, type your user name and password, and then click Sign in using our secure server.
Under Access Credentials, on the Access Keys tab, your access key ID is displayed. To view your secret key, under Secret Access Key, click Show.
Do not share your secret access key with anyone. Anyone who has access to your secret access key will be able to use AWS services in your name 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 AWS CloudFormation CLI with the
SECRETKEY with your AWS credentials. You will need to do this every time you issue an AWS
To add your AWS credentials to the AWS credential file
Open the terminal if you don't have it open already, and change your working directory to the AWS CloudFormation
CLI installation directory. For example, if you made a link to your installation directory called
cfn as suggested previously, At the command prompt, type the following, and then press Enter:
$ cd ~/.awstools/cfn
(Optional) Copy or rename
credential-file-path.template For this example, we'll
myAWSCredentials.txt. At the command prompt, type the following, and then press Enter:
$ cp credential-file-path.template myAWSCredentials.txt
Edit the file with your favorite text editor (both
are installed by default on Ubuntu), enter your AWS credentials as shown, and then save and close the file.
Note: These are only example values. Enter your own AWS security credentials in the file.
Finally, you'll need to add a few environment variables to your system. Because you'll be using the AWS CloudFormation
CLI from the command-line, you can simply add these variables to your
To add the AWS CloudFormation CLI tools environment variables:
~/.bashrc (or the equivalent terminal startup file for your Linux variant) in your
favorite editor. If this file does not exist yet, create it.
~/.bashrc, add the following lines, substituting the appropriate directories on your
# AWS CloudFormation CLI tools setup export JAVA_HOME="/usr/lib/jvm/default-java/jre/" export AWS_CLOUDFORMATION_HOME="$HOME/.awstools/cfn" export AWS_CREDENTIAL_FILE="$AWS_CLOUDFORMATION_HOME/myAWSCredentials.txt" export PATH="$PATH:$AWS_CLOUDFORMATION_HOME/bin"
If you did not add your AWS access keys to an external file (such as the
myAWSCredentials.txt file specified earlier), you should not include
AWS_CREDENTIAL_FILE environment variable.
On Ubuntu Linux,
default-java is a link to the default Java installation, which
is typically OpenJDK. OpenJDK works fine with the AWS CloudFormation command-line tools. If you prefer a different
Java runtime, you can reset
default-java to point to your preferred runtime
location, or you can set the location of your preferred runtime as the value of
To load your environment variables, either quit and restart the terminal or, at the command prompt, At the command prompt, type the following, and then press Enter:
Test your installation by running cfn-cmd. At the command prompt, type the following, and then press Enter:
This command will list all of the available AWS CloudFormation CLI commands, their usage, and the available options
for cfn-cmd itself (there are two options: