Amazon EC2 Auto Scaling
User Guide

Creating an Auto Scaling Group Using a Launch Template

This section shows you how to create 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 and the minimum number of instances your group must maintain at all times. When you use a launch template, you can have multiple launch template versions where you specify different launch parameters.

When you create an Auto Scaling group using a launch template, 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.

Note

If you currently use launch configurations, you can specify a launch template when you update an Auto Scaling group that was created using a launch configuration. You can also create launch templates from existing launch configurations. For more information, see Copying a Launch Configuration to a Launch Template.

The following procedure demonstrates how to create an Auto Scaling group using an existing launch template.

Prerequisites

  • You must ensure that your launch template includes all parameters required to launch an EC2 instance, such as an AMI ID and an instance type. Otherwise, when you use the template to create an Auto Scaling group, you receive an error that you must use a fully formed launch template. For more information, see Launching an Instance from a Launch Template in the Amazon EC2 User Guide for Linux Instances.

  • 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 Launch Templates in the Amazon EC2 User Guide for Linux Instances.

Limitations

The following are limitations when creating a launch template for use with an Auto Scaling group:

  • You cannot specify multiple network interfaces.

  • If you specify a network interface, its device index must be 0.

  • If you specify a network interface, you must specify any security groups as part of the network interface, and not in the Security Groups section of the template.

  • You cannot specify private IP addresses.

  • You cannot use host placement affinity.

  • If you specify Spot Instances, you must specify a one-time request with no end date.

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, do the following:

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

    2. For Group name, type a name for your Auto Scaling group.

    3. For Group size, type the initial number of instances for your Auto Scaling group.

    4. (Optional) To override the network in the launch template, select a VPC for Network.

    5. (Optional) To override the network in the launch template, select one or more subnets for Subnet.

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

    7. Choose Next: Configure scaling policies.

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

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

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

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

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