Friday, May 24, 2013

AWS Auto Scaling Part 1 - Configuring Auto Scaling Command Line Tools

In this post, we will experiment with Amazon's auto scaling service.

We will first begin by installing the Auto Scaling Command Line Tools in a new Ubuntu machine.

Connect to your machine by ssh.


Download and Unzip the Auto Scaling Command Line Tools

mkdir /opt/tools
cd /opt/tools
wget http://ec2-downloads.s3.amazonaws.com/AutoScaling-2011-01-01.zip

sudo apt-get install unzip
unzip AutoScaling-2011-01-01.zip


Install Java

Read Install Java OpenJDK 7 on Amazon EC2 Ubuntu.


Setting the environment variables

In your  ~/.bashrc file, append the following lines to the end of the file.
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
export PATH=$JAVA_HOME/bin:$PATH
Set the AWS_AUTO_SCALING_HOME to the location where you unzipped the command line tools.

export AWS_AUTO_SCALING_HOME=/opt/tools/AutoScaling-1.0.61.2
export PATH=$PATH:$AWS_AUTO_SCALING_HOME/bin

Install the Security Credentials

Go to the AWS security console.

Scroll to the Access Credentials section.

Note down an active pair of Access Key ID and Secret Access Key (Click show to see the secret access key).
vi /opt/tools/AutoScaling-1.0.61.2/credential-file-path.template
Paste your keys:
AWSAccessKeyId=
AWSSecretKey=
Append to ~/.bashrc
export AWS_CREDENTIAL_FILE=/opt/tools/AutoScaling-1.0.61.2/credential-file-path.template

Setting the Auto Scaling Region

By default, the auto scaling region is us-east-1.

If want to use a different region, you need to change to your region. Note down the region endpoint here: Regions and Endpoints.
vi ~/.bashrc
export AWS_AUTO_SCALING_URL=https://autoscaling.us-east-1.amazonaws.com

Test your configuration

as-cmd

You should see a panel of commands like 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 ' --help'

In Part 2, we will go through an example that will launch an instance via a auto scaling group.

1 comment: