Migrate your Auto Scaling groups to launch templates - Amazon EC2 Auto Scaling

Migrate your Auto Scaling groups to launch templates

Starting in 2023, you can not call CreateLaunchConfiguration with new Amazon EC2 instance types released after December 31, 2022. For more information, see Auto Scaling launch configurations.

To migrate your Auto Scaling groups from launch configurations to launch templates, see the following steps.

Important

Before you continue, confirm that you have the permissions required to work with launch templates. For more information, see Permissions to work with launch templates.

Step 1: Find Auto Scaling groups that use launch configurations

To identify whether you have Auto Scaling groups that are still using launch configurations, run the following describe-auto-scaling-groups command using the AWS CLI. Replace REGION with your AWS Region.

aws autoscaling describe-auto-scaling-groups --region REGION \ --query 'AutoScalingGroups[?LaunchConfigurationName!=`null`]'

The following is example output.

[ { "AutoScalingGroupName": "group-1", "AutoScalingGroupARN": "arn", "LaunchConfigurationName": "my-launch-config", "MinSize": 1, "MaxSize": 5, "DesiredCapacity": 2, "DefaultCooldown": 300, "AvailabilityZones": [ "us-west-2a", "us-west-2b", "us-west-2c" ], "LoadBalancerNames": [], "TargetGroupARNs": [], "HealthCheckType": "EC2", "HealthCheckGracePeriod": 300, "Instances": [ { "ProtectedFromScaleIn": false, "AvailabilityZone": "us-west-2a", "LaunchConfigurationName": "my-launch-config", "InstanceId": "i-05b4f7d5be44822a6", "InstanceType": "t3.micro", "HealthStatus": "Healthy", "LifecycleState": "InService" }, { "ProtectedFromScaleIn": false, "AvailabilityZone": "us-west-2b", "LaunchConfigurationName": "my-launch-config", "InstanceId": "i-0c20ac468fa3049e8", "InstanceType": "t3.micro", "HealthStatus": "Healthy", "LifecycleState": "InService" } ], "CreatedTime": "2023-03-09T22:15:11.611Z", "SuspendedProcesses": [], "VPCZoneIdentifier": "subnet-5ea0c127,subnet-6194ea3b,subnet-c934b782", "EnabledMetrics": [], "Tags": [ { "ResourceId": "group-1", "ResourceType": "auto-scaling-group", "Key": "environment", "Value": "production", "PropagateAtLaunch": true } ], "TerminationPolicies": [ "Default" ], "NewInstancesProtectedFromScaleIn": false, "ServiceLinkedRoleARN": "arn", "TrafficSources": [] }, ... additional groups ... ]

Alternatively, to remove everything except the Auto Scaling group names with the names of their respective launch configurations and tags in the output, run the following command:

aws autoscaling describe-auto-scaling-groups --region REGION \ --query 'AutoScalingGroups[?LaunchConfigurationName!=`null`].{AutoScalingGroupName: AutoScalingGroupName, LaunchConfigurationName: LaunchConfigurationName, Tags: Tags}'

The following shows example output.

[ { "AutoScalingGroupName": "group-1", "LaunchConfigurationName": "my-launch-config", "Tags": [ { "ResourceId": "group-1", "ResourceType": "auto-scaling-group", "Key": "environment", "Value": "production", "PropagateAtLaunch": true } ] }, ... additional groups ... ]

For more information about filtering, see Filtering AWS CLI output in the AWS Command Line Interface User Guide.

Step 2: Copy a launch configuration to a launch template

You can copy a launch configuration to a launch template using the following procedure. Then, you can add it to your Auto Scaling group.

Copying multiple launch configurations results in identically named launch templates. To change the name given to a launch template during the copying process, you must copy the launch configurations one by one.

Note

The copying feature is available only from the console.

To copy a launch configuration to a launch template (console)
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the left navigation pane, under Auto Scaling, choose Auto Scaling Groups.

  3. Choose Launch configurations near the top of the page. When prompted for confirmation, choose View launch configurations to confirm that you want to view the Launch configurations page.

  4. Select the launch configuration you want to copy and choose Copy to launch template, Copy selected. This sets up a new launch template with the same name and options as the launch configuration that you selected.

  5. For New launch template name, you can use the name of the launch configuration (the default) or enter a new name. Launch template names must be unique.

  6. (Optional) Select Create an Auto Scaling group using the new template.

    You can skip this step to finish copying the launch configuration. You do not need to create a new Auto Scaling group.

  7. Choose Copy.

To copy all launch configurations to launch templates (console)
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation pane, under Auto Scaling, choose Launch Configurations.

  3. Choose Copy to launch template, Copy all. This copies each launch configuration in the current Region to a new launch template with the same name and options.

  4. Choose Copy.

Step 3: Update an Auto Scaling group to use a launch template

After creating a launch template, you're ready to add it to your Auto Scaling group.

To update an Auto Scaling group to use a launch template (console)
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/, and choose Auto Scaling Groups from the navigation pane.

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

To update an Auto Scaling group to use a launch template (AWS CLI)

The following update-auto-scaling-group command updates the specified Auto Scaling group to use the initial version of the specified launch template.

aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg \ --launch-template LaunchTemplateName=my-template-for-auto-scaling,Version='1'

For more examples of using CLI commands to update an Auto Scaling group to use a launch template, see Update an Auto Scaling group to use a launch template.

Step 4: Replace your instances

After you replace the launch configuration with a launch template, any new instances will use the new launch template. Existing instances are not affected.

To update the existing instances, you can start an instance refresh to replace the instances in your Auto Scaling group instead of manually replacing instances a few at a time. For more information, see Use an instance refresh to update instances in an Auto Scaling group. If the group is large, an instance refresh can be particularly helpful.

Alternatively, you can allow automatic scaling to gradually replace existing instances with new instances based on the group's termination policies, or you can terminate them. Manual termination forces your Auto Scaling group to launch new instances to maintain the group's desired capacity. For more information, see Terminate an instance in the Amazon EC2 User Guide.

Additional information

For more information, see Amazon EC2 Auto Scaling will no longer add support for new EC2 features to Launch Configurations on the AWS Compute Blog.

For a topic that takes you through how to migrate AWS CloudFormation stacks from launch configurations to launch templates, see Migrate AWS CloudFormation stacks to launch templates.