Replacing a launch configuration with a launch template - Amazon EC2 Auto Scaling

Replacing a launch configuration with a launch template

When you edit an Auto Scaling group that has an existing launch configuration, you have the option of replacing the launch configuration with a launch template. This lets you use launch templates with any Auto Scaling groups that you currently use. In doing so, you can take advantage of the versioning and other features of launch templates.

After you replace the launch configuration for an Auto Scaling group, any new instances are launched using the new launch template, but existing instances are not affected. To update the existing instances, terminate them so that they are replaced by your Auto Scaling group, or allow automatic scaling to gradually replace older instances with newer instances based on your termination policies.

Note

With the maximum instance lifetime and instance refresh features, you can also replace all instances in the Auto Scaling group to launch new instances that use the launch template. For more information, see Replacing Auto Scaling instances based on maximum instance lifetime and Replacing Auto Scaling instances based on an instance refresh.

Prerequisites

Before you can replace a launch configuration in an Auto Scaling group, you must first create your launch template. The easiest way to create a launch template is to copy it from the launch configuration. For more information, see Copying a launch configuration to a launch template.

When you replace a launch configuration with a launch template, your ec2:RunInstances permissions are checked. If you are attempting to use a launch template and you do not have sufficient permissions, you receive an error that you're not authorized to use the launch template. For information about the required IAM permissions, see Launch template support.

To replace the launch configuration for an Auto Scaling group (console)

  1. Open the Amazon EC2 Auto Scaling console at https://console.aws.amazon.com/ec2autoscaling/.

  2. Select the check box next to your Auto Scaling group.

    A split pane opens up in the bottom part of the page, showing information about the group that's selected.

  3. On the Details tab, choose Launch configuration, Edit.

  4. Choose Switch to launch template.

  5. For Launch template, select your launch template.

  6. For Version, select the launch template version, as needed. After you create versions of a launch template, you can choose whether the Auto Scaling group uses the default or the latest version of the launch template when scaling out.

  7. When you have finished, choose Update.

To replace a launch configuration using the command line

You can use one of the following commands:

For examples of using a CLI command to update an Auto Scaling group to use a launch template, see Updating an Auto Scaling group to use a launch template.