Auto Scaling
Getting Started Guide (API Version 2011-01-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

Set Up the Command Line Interface

Set Up The Auto Scaling Command Line Interface

This section describes how to set up the Auto Scaling command line interface.

Installing the Command Line Interface


Note

As a convention, command line text is prefixed with a generic PROMPT> command line prompt. The actual command line prompt on your computer is likely to be different. We also use $ to indicate a Linux/UNIX–specific command and C:\> for a Windows–specific command. Although we don't provide explicit instructions, the tool also works on the Mac OS X. (Commands on the Mac OS X resemble the Linux and UNIX commands.) The example output resulting from the command is shown immediately thereafter without any prefix.

Task 1: Download the Command Line Interface

The command line tool is available as a ZIP file on Auto Scaling Command Line Tools. The tool is written in Java and includes shell scripts for both Windows and Linux/UNIX/Mac OSX. The ZIP file is self-contained; no installation is required. You just download it and unzip it.

Some additional setup is required before you can use the tool. These steps are discussed next.

Task 2: Set the JAVA_HOME environment variable

The Auto Scaling command line tool reads an environment variable (JAVA_HOME) on your computer to locate the Java runtime. The command line tool requires Java version 5 or later to run. Either a JRE or JDK installation is acceptable.

To set the JAVA_HOME Environment Variable

  1. If you do not have Java 1.5 or later installed, download and install it now. To view and download JREs for a range of platforms, including Linux/UNIX and Windows, go to http://java.oracle.com/.

  2. Set JAVA_HOME to the full path of the directory that contains a subdirectory named bin that in turn contains the Java executable. For example, if your Java executable is in the /usr/jdk/bin directory, set JAVA_HOME to /usr/jdk. If your Java executable is in C:\jdk\bin, set JAVA_HOME to C:\jdk.

    Note

    If you are using Cygwin tool to provide a Linux look and feel environment for Windows, you must use Linux/UNIX paths (e.g., /usr/bin instead of C:\usr\bin) for AWS_AUTO_SCALING_HOME and AWS_CREDENTIAL_FILE. However, JAVA_HOME should have a Windows path. Additionally, the value cannot contain any spaces, even if the value is quoted or the spaces are escaped.

    The following Linux/UNIX example sets JAVA_HOME for a Java executable in the /usr/local/jre/bin directory.

    $ export JAVA_HOME=/usr/local/jre

    The following Windows example uses set and setx to set JAVA_HOME for a Java executable in the C:\java\jdk1.6.0_6\bin directory. The set command defines JAVA_HOME for the current session and setx makes the change permanent.

    C:\> set JAVA_HOME=C:\java\jdk1.6.0_6
    C:\> setx JAVA_HOME C:\java\jdk1.6.0_6

    Note

    Don't include the bin directory in JAVA_HOME; that's a common mistake some users make. The command line tool won't work if you do.

  3. Add your Java directory to your path before other versions of Java.

    On Linux and UNIX, you can update your PATH as follows:

    $ export PATH=$JAVA_HOME/bin:$PATH 

    On Windows the syntax is slightly different:

    C:\> set PATH=%JAVA_HOME%\bin;%PATH% 
    C:\> setx PATH %JAVA_HOME%\bin;%PATH% 

    Note

    The setx command does not use the = sign.

  4. On Linux or UNIX, verify your JAVA_HOME setting with the command $JAVA_HOME/bin/java -version.

    $ $JAVA_HOME/bin/java -version
    java version "1.5.0_09"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)

    The syntax is different on Windows, but the output is similar.

    C:\> %JAVA_HOME%\bin\java -version
    java version "1.5.0_09"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)

Task 3: Set the AWS_AUTO_SCALING_HOME environment variable

The command line tool depends on an environment variable (AWS_AUTO_SCALING_HOME) to locate supporting libraries. You'll need to set this environment variable before you can use the tool.

To set the AWS_AUTO_SCALING_HOME Environment Variable

  1. Set AWS_AUTO_SCALING_HOME to the path of the directory into which you unzipped the command line tool. This directory is named as-w.x.y.z (w, x, y, and z are version/release numbers) and contains subdirectories named bin and lib.

    The following Linux/UNIX example sets AWS_AUTO_SCALING_HOME for a directory named as-1.0.12.0 in the /usr/local directory.

    $ export AWS_AUTO_SCALING_HOME=/usr/local/as-1.0.12.0  

    The following Windows example sets AWS_AUTO_SCALING_HOME for a directory named as-1.0.12.0 in the C:\CLIs directory.

    C:\> set AWS_AUTO_SCALING_HOME=C:\CLIs\as-1.0.12.0 
    C:\> setx AWS_AUTO_SCALING_HOME C:\CLIs\as-1.0.12.0             
  2. Add the tool's bin directory to your system PATH. The rest of this guide assumes that you've done this.

    On Linux and UNIX, you can update your PATH as follows:

    $ export PATH=$PATH:$AWS_AUTO_SCALING_HOME/bin 

    On Windows the syntax is slightly different:

    C:\> set PATH=%PATH%;%AWS_AUTO_SCALING_HOME%\bin 
    C:\> setx PATH %PATH%;%AWS_AUTO_SCALING_HOME%\bin 

Task 4: Set the AWS_CREDENTIAL_FILE environment variable

You must also provide your AWS credentials to the command line tool. The command line tool reads your credentials from a credential file that you create on your local system.

You can either specify your credentials with the --aws-credential-file parameter every time you issue a command, or you can create an environment variable that points to the credential file on your local system. If the environment variable is properly configured, you can omit the --aws-credential-file parameter when you issue a command. The following procedure describes how to create a credential file and a corresponding AWS_CREDENTIAL_FILE environment variable.

To set up security credentials for your command line tool

  1. Log in to the AWS security credentials website.

  2. Retrieve an access key and its corresponding secret key.

    1. Scroll down to the Access Credentials section and select the Access Keys tab.

    2. Locate an active Access Key in the Your Access Keys list.

    3. To display the Secret Access Key, click Show in the Secret Access Key column.

    4. Write down the keys or save them.

    5. If no Access Keys appear in the list, click Create a New Access Key and follow the on-screen prompts.

  3. Add your access key ID and secret access key to the file named credential-file-path.template:

    1. Open the file credential-file-path.template included in your command line interface (CLI) archive.

    2. Copy and paste your access key ID and secret access key into the file.

    3. Rename the file and save it to a convenient location on your computer.

    4. If you are using Linux, set the file permissions as follows:

      $ chmod 600 credential-file-name

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

    The following Linux/UNIX example sets AWS_CREDENTIAL_FILE for myCredentialFile in the /usr/local directory.

    $ export AWS_CREDENTIAL_FILE=/usr/local/myCredentialFile  

    The following Windows example sets AWS_CREDENTIAL_FILE for myCredentialFile.txt in the C:\aws directory.

    C:\> set AWS_CREDENTIAL_FILE=C:\aws\myCredentialFile.txt 
    C:\> setx AWS_CREDENTIAL_FILE C:\aws\myCredentialFile.txt 

Task 5: Set the Region

By default, the Auto Scaling command line interface (CLI) uses the Eastern United States Region (us-east-1) with the autoscaling.us-east-1.amazonaws.com service endpoint URL. If your instances are in a different region, you must specify the region where your instances reside. For example, if your instances are in Europe, you must specify the eu-west-1 Region by using the --region eu-west-1 parameter or by setting the AWS_AUTO_SCALING_URL environment variable.

This section describes how to specify a different region by changing the service endpoint URL.

To specify a different region

  1. To view available regions go to Regions and Endpoints in the Amazon Web Services General Reference.

  2. If you want to change the service endpoint, set the AWS_AUTO_SCALING_URL environment variable.

    • The following Linux/UNIX example sets AWS_AUTO_SCALING_URL to the EU (Ireland) Region.

      $ export AWS_AUTO_SCALING_URL=https://autoscaling.eu-west-1.amazonaws.com  
    • The following Windows example sets AWS_AUTO_SCALING_URL to the EU (Ireland) Region.

      C:\> set AWS_AUTO_SCALING_URL=https://autoscaling.eu-west-1.amazonaws.com  
      C:\> setx AWS_AUTO_SCALING_URL https://autoscaling.eu-west-1.amazonaws.com  

Task 6: Test Your Configuration

To test your Auto Scaling installation and configuration

  1. On your Linux or Windows workstation, open a new command prompt.

  2. Type the command as-cmd.

  3. You should see output similar to the following:

    Command Name                                Description                                            
    ------------                                -----------                                            
    as-create-auto-scaling-group                Create a new Auto Scaling group.
    as-create-launch-config                     Creates a new launch configuration.
    as-create-or-update-tags                    Create or update tags.
    as-delete-auto-scaling-group                Deletes the specified Auto Scaling group.
    as-delete-launch-config                     Deletes the specified launch configuration.
    as-delete-notification-configuration        Deletes the specified notification configuration.
    as-delete-policy                            Deletes the specified policy.
    as-delete-scheduled-action                  Deletes the specified scheduled action.
    as-delete-tags                              Delete the specified tags
    as-describe-adjustment-types                Describes all policy adjustment types.
    as-describe-auto-scaling-groups             Describes the specified Auto Scaling groups.
    as-describe-auto-scaling-instances          Describes the specified Auto Scaling instances.
    as-describe-auto-scaling-notification-types Describes all Auto Scaling notification types.
    as-describe-launch-configs                  Describes the specified launch configurations.
    as-describe-metric-collection-types         Describes all metric colle... metric granularity types.
    as-describe-notification-configurations     Describes all notification...given Auto Scaling groups.
    as-describe-policies                        Describes the specified policies.
    as-describe-process-types                   Describes all Auto Scaling process types.
    as-describe-scaling-activities              Describes a set of activit...ties belonging to a group.
    as-describe-scheduled-actions               Describes the specified scheduled actions.
    as-describe-tags                            Describes tags
    as-describe-termination-policy-types        Describes all Auto Scaling termination policy types.
    as-disable-metrics-collection               Disables collection of Auto Scaling group metrics.
    as-enable-metrics-collection                Enables collection of Auto Scaling group metrics.
    as-execute-policy                           Executes the specified policy.
    as-put-notification-configuration           Creates or replaces notifi...or the Auto Scaling group.
    as-put-scaling-policy                       Creates or updates an Auto Scaling policy.
    as-put-scheduled-update-group-action        Creates or updates a scheduled update group action.
    as-resume-processes                         Resumes all suspended Auto... given Auto Scaling group.
    as-set-desired-capacity                     Sets the desired capacity of the Auto Scaling group.
    as-set-instance-health                      Sets the health of the instance.
    as-suspend-processes                        Suspends all Auto Scaling ... given Auto Scaling group.
    as-terminate-instance-in-auto-scaling-group Terminates a given instance.
    as-update-auto-scaling-group                Updates the specified Auto Scaling group.
    help
    version                                     Prints the version of the CLI tool and the API.
    
        For help on a specific command, type '<commandname> --help'
    

This completes your installation and configuration of the Auto Scaling command line tools. You're ready to start accessing Auto Scaling using the command line interface (CLI). For descriptions of all the Auto Scaling commands, see Auto Scaling Quick Reference Card.

Create Auto Scaling Group