Creating an Auto Scaling group using a launch template - Amazon EC2 Auto Scaling

Creating an Auto Scaling group using a launch template

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

With launch templates, you can configure the Auto Scaling group to dynamically choose either the default version or the latest version of the launch template when a scale-out event occurs. For example, you configure your Auto Scaling group to choose the current default version of a launch template. To change the configuration of the EC2 instances to be launched by the group, create or designate a new default version of the launch template. Alternatively, you can choose the specific version of the launch template that the group uses to launch EC2 instances. You can change these selections anytime by updating the group.

Each launch template includes the information that Amazon EC2 needs to launch instances, such as an AMI and instance type. You can create an Auto Scaling group that adheres to the launch template. Or, you can override the instance type in the launch template and combine On-Demand and Spot Instances. For more information, see Auto Scaling groups with multiple instance types and purchase options.

The Auto Scaling group specifies the desired capacity and additional information that Amazon EC2 needs to launch instances, such as the Availability Zones and VPC subnets. You can set capacity to a fixed number of instances, or you can take advantage of automatic scaling to adjust capacity based on actual demand.

Prerequisites

  • You must have created a 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.

  • You must have IAM permissions to create an Auto Scaling group using a launch template and also to create EC2 resources for the instances. For more information, see Launch template support.

Amazon EC2 Auto Scaling has changed the user interface. By default, you're shown the new user interface, but you can choose to return to the old user interface. This topic contains steps for each.

To create an Auto Scaling group using a launch template (new console)

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

  2. On the navigation bar at the top of the screen, choose the same AWS Region that you used when you created the launch template.

  3. On the navigation pane, under AUTO SCALING, choose Auto Scaling Groups.

  4. Choose Create an Auto Scaling group.

  5. On the Choose launch template or configuration page, do the following:

    1. For Auto Scaling group name, enter a name for your Auto Scaling group.

    2. For Launch Template, choose an existing launch template.

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

    4. Verify that your launch template supports all of the options that you are planning to use, and then choose Next.

  6. On the Configure settings page, for Purchase options and instance types, choose Adhere to the launch template to use the EC2 instance type and purchase option that are specified in the launch template.

  7. Under Network, for VPC, choose the VPC for the security groups that you specified in your launch template. Launching instances using a combination of instance types and purchase options is not supported in EC2-Classic.

  8. For Subnet, choose one or more subnets in the specified VPC. Use subnets in multiple Availability Zones for high availability. For more information about high availability with Amazon EC2 Auto Scaling, see Distributing Instances Across Availability Zones.

  9. Choose Next.

    Or, you can accept the rest of the defaults, and choose Skip to review.

  10. (Optional) On the Configure advanced options page, configure the following options, and then choose Next:

    1. To register your Amazon EC2 instances with a load balancer, choose Enable load balancing, and choose an existing load balancer or create a new one. If you use an Application Load Balancer or Network Load Balancer, choose a target group where you register targets by instance ID.

    2. To enable your Elastic Load Balancing (ELB) health checks, for Health checks, choose ELB under Health check type. These health checks are optional when you enable load balancing.

    3. Under Health check grace period, enter the amount of time until Amazon EC2 Auto Scaling checks the health of instances after they are put into service. The intention of this setting is to prevent Amazon EC2 Auto Scaling from marking instances as unhealthy and terminating them before they have time to come up. The default is 300 seconds.

  11. (Optional) On the Configure group size and scaling policies page, configure the following options, and then choose Next:

    1. For Desired capacity, enter the initial number of instances to launch. When you change this number to a value outside of the minimum or maximum capacity limits, you must update the values of Minimum capacity or Maximum capacity. For more information, see Setting capacity limits for your Auto Scaling group.

    2. To automatically scale the size of the Auto Scaling group, choose Target tracking scaling policy and follow the directions. For more information, see Target Tracking Scaling Policies.

    3. Under Instance scale-in protection, choose whether to enable instance scale-in protection. For more information, see Instance scale-in protection.

  12. (Optional) To receive notifications, for Add notification, configure the notification, and then choose Next. For more information, see Getting Amazon SNS notifications when your Auto Scaling group scales.

  13. (Optional) To add tags, choose Add tag, provide a tag key and value for each tag, and then choose Next. For more information, see Tagging Auto Scaling groups and instances.

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

To create an Auto Scaling group using a launch template (old console)

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

  2. On the navigation bar at the top of the screen, choose the same AWS Region that you used when you created the launch template.

  3. On the navigation pane, under AUTO SCALING, choose Auto Scaling Groups.

  4. Choose Create Auto Scaling group.

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

  6. On the Configure Auto Scaling group details page, for Group name, enter 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 that are specified in the launch template.

    Note

    Alternatively, to launch instances across multiple instance types using both On-Demand and Spot purchase options, choose Combine purchase options and instances. For more information, see Auto Scaling groups with multiple instance types and purchase options.

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

  10. For Network, choose a VPC for your Auto Scaling group.

  11. For Subnet, choose one or more subnets in the specified VPC. Use subnets in multiple Availability Zones for high availability. For more information about high availability with Amazon EC2 Auto Scaling, see Distributing Instances Across Availability Zones.

  12. (Optional) To register your Amazon EC2 instances with a load balancer, choose Advanced Details, choose Receive traffic from one or more load balancers, and choose one or more Classic Load Balancers or target groups.

  13. Choose Next: Configure scaling policies.

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

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

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

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

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

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

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