Amazon EC2 Auto Scaling
User Guide

Creating an Auto Scaling Group Using a Launch Template

When you create an Auto Scaling group, you must specify the information needed to configure the EC2 instances, the subnets for the instances, and the initial number of instances to start with.

To configure Auto Scaling instances, you can specify a launch configuration, a launch template, or an EC2 instance. The following procedure demonstrates how to create an Auto Scaling group using a launch template.

With launch templates, you select the launch template and which specific version of the launch template the group uses to launch EC2 instances. You can change these selections anytime by updating the group.

Alternatively, you can configure the Auto Scaling group to select either the default version or the latest version of the launch template dynamically when a scale-out event occurs. For example, if you configure your Auto Scaling group to select the default version of a launch template dynamically, you can change the configuration of the EC2 instances to be launched by the group by creating or designating a new default version of the launch template.

For more information, see Launch Templates.

Prerequisites

  • You must have an existing launch template that includes the parameters required to launch an EC2 instance. For information about these parameters and the limitations that apply when creating a launch template for use with an Auto Scaling group, see Creating a Launch Template for an Auto Scaling group.

  • An IAM user or role that creates an Auto Scaling group using a launch template must have permission to use the ec2:RunInstances action and permission to create or use the resources for the instance. For example, access to the iam:PassRole action is required to use an instance profile. You can use the AmazonEC2FullAccess policy to grant full access to all Amazon EC2 resources. You can use resource-level permissions to restrict access to specific launch templates. For more information, see Require a Launch Template or Working with launch templates in the Amazon EC2 User Guide for Linux Instances.

To create an Auto Scaling group using a launch template

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation bar at the top of the screen, select the same region that you used when you created the launch template.

  3. In the navigation pane, choose Auto Scaling Groups.

  4. Choose Create Auto Scaling group.

  5. Choose Launch Template, select your launch template, and then choose Next Step.

  6. On the Configure Auto Scaling group details page, for Group name, type a name for your Auto Scaling group.

  7. For Launch template version, choose whether the Auto Scaling group uses the default, the latest, or a specific version of the launch template when scaling out.

  8. For Fleet Composition, choose Adhere to the launch template to use the EC2 instance type and purchase option specified in the launch template or Combine purchase options and instances to launch instances across multiple instance types using both On-Demand and Spot purchase options.

  9. If you chose to combine purchase options and instance types:

    1. For Instance Types, choose the optimal instance family and instance size (such as c5.large) that may be launched. The order in which you add instance types sets their priority for On-Demand Instances. The instance type at the top of the list is prioritized the highest when the Auto Scaling group launches your On-Demand capacity. You must specify at least two instance types, up to a maximum of 20.

    2. For Instances Distribution, choose whether to keep or replace the default instance distribution settings.

    3. If you chose to replace the default settings, provide the following information:

      • For Maximum Spot Price, choose Use default to cap your maximum Spot price at the On-Demand price or Set your maximum price to specify the maximum price you are willing to pay per instance per hour for Spot Instances. For information about Amazon EC2 pricing, see Amazon EC2 Pricing.

      • For Spot Allocation Strategy, choose the number of Spot pools (instances of the same type and OS within an Availability Zone) to allocate your Spot Instances across.

      • For Optional On-Demand Base, specify the minimum amount of the Auto Scaling group's initial capacity that must be fulfilled by On-Demand Instances, or leave blank to launch On-Demand Instances as a percentage of the group's desired capacity.

      • For On-Demand Percentage Above Base, specify the percentages of On-Demand Instances and Spot Instances for your additional capacity beyond the optional On-Demand base amount.

  10. For Group size, enter the initial number of instances for your Auto Scaling group.

  11. For Network, select a VPC for your Auto Scaling group.

    Note

    Launching instances using a combination of instance types and On-Demand and Spot purchase options is not supported in EC2-Classic.

  12. For Subnet, select one or more subnets in the specified VPC.

  13. (Optional) To register your Auto Scaling instances with a load balancer, select Receive traffic from one or more load balancers and select one or more Classic Load Balancers or target groups.

  14. Choose Next: Configure scaling policies.

  15. On the Configure scaling policies page, select one of the following options, and then choose Next: Configure Notifications:

    • To manually adjust the size of the Auto Scaling group as needed, select Keep this group at its initial size. For more information, see Manual Scaling.

    • To automatically adjust the size of the Auto Scaling group based on criteria that you specify, select Use scaling policies to adjust the capacity of this group and follow the directions. For more information, see Configure Scaling Policies.

  16. (Optional) To receive notifications, choose Add notification, configure the notification, and then choose Next: Configure Tags.

  17. (Optional) To add tags, choose Edit tags, provide a tag key and value for each tag, and then choose Review.

    Alternatively, you can add tags later on. For more information, see Tagging Auto Scaling Groups and Instances.

  18. On the Review page, choose Create Auto Scaling group.

  19. On the Auto Scaling group creation status page, choose Close.

To create an Auto Scaling group using the command line

You can use one of the following commands: