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...

Create an Auto Scaling Group

Create an Auto Scaling Group

Now that you have installed the Auto Scaling CLI, you're ready to create an Auto Scaling group. You'll use the command-line tools to create a simple Auto Scaling group designed to contain exactly one EC2 instance.

First, you'll create a launch configuration that specifies the type of EC2 instance that you want Auto Scaling to create. Second, you'll create an Auto Scaling group that references your launch configuration. Finally, you'll verify that the Auto Scaling group is functioning.

Create a Launch Configuration

The launch configuration specifies the type of Amazon EC2 instance that Auto Scaling creates for you. To create a launch configuration with as-create-launch-config, you must specify an Amazon Machine Image (AMI) ID and an Amazon EC2 instance type similar to the following example:

  • AMI ID: ami-2272864b

  • Instance type: m1.large

Note

The AMI ID is provided for illustration purposes only. AMI IDs change over time. You can obtain current, valid AMI IDs by calling the ec2-describe-images CLI command.

To create a launch configuration

  • Open a command prompt and enter the as-create-launch-config command.

    as-create-launch-config MyLC --image-id ami-2272864b --instance-type m1.large

    Auto Scaling returns the following:

    OK-Created launch config

Create an Auto Scaling Group

After you have defined your launch configuration, you are ready to create an Auto Scaling group. To create an Auto Scaling group with as-create-auto-scaling-group, you must specify a name for your group, a launch configuration, one or more Availability Zones, a minimum group size, and a maximum group size.

Name your Auto Scaling group "MyGroup" and use the launch configuration you created previously. The Availability Zones you choose determine the physical location of your Auto Scaling instances. For this example, specify a single zone: us-east-1a. Set the minimum and maximum size of your Auto Scaling group to 1. Because the minimum size of the group is 1, Auto Scaling begins creating an EC2 instance immediately after you call as-create-auto-scaling-group.

Important

The instance you're about to launch will be live (and not running in a sandbox). You will incur the standard Amazon EC2 usage fees for the instance until you terminate it as the last task in this tutorial. The total charges will be minimal (typically less than a dollar). For more information about Amazon EC2 usage rates, go to the Amazon EC2 product page.

To create an Auto Scaling group

  • Enter the as-create-auto-scaling-group command.

    as-create-auto-scaling-group MyGroup --launch-configuration MyLC --availability-zones us-east-1a --min-size 1 --max-size 1

    Auto Scaling returns the following:

    OK-Created AutoScalingGroup

Verify Auto Scaling Group Creation

You can use the as-describe-auto-scaling-groups command to check whether the MyGroup Auto Scaling group exists. Use the --headers parameter to print headings that describe each value that the command returns.

To verify that the Auto Scaling group exists

  • Enter the as-describe-auto-scaling-groups command.

    as-describe-auto-scaling-groups --headers

    Auto Scaling returns the following:

    AUTO-SCALING-GROUP  GROUP-NAME   LAUNCH-CONFIG  AVAILABILITY-ZONES  MIN-SIZE  MAX-SIZE  DESIRED-CAPACITY
    AUTO-SCALING-GROUP  MyGroup      MyLC           us-east-1a          1         1         1

You can also use the as-describe-auto-scaling-instances command to check whether the MyGroup Auto Scaling group contains any running instances. Use the --headers parameter to print headings that describe each value that the command returns.

To verify that MyGroup contains an EC2 instance

  • Enter the as-describe-auto-scaling-instances command.

    as-describe-auto-scaling-instances --headers

    Auto Scaling returns the following (your INSTANCE-ID will differ):

    INSTANCE  INSTANCE-ID  GROUP-NAME   AVAILABILITY-ZONE  STATE      STATUS   LAUNCH-CONFIG
    INSTANCE  i-bcdd63d1   MyGroup      us-east-1a         InService  HEALTHY  MyLC

You have a number of other options when you use as-create-auto-scaling-group, as-describe-auto-scaling-groups, and as-describe-auto-scaling-instances. For more information, go to the Auto Scaling API Reference.

Delete Group