Menu
Auto Scaling
User Guide

Creating a Launch Configuration Using an EC2 Instance

Auto Scaling provides you with an option to create a launch configuration using the attributes from a running EC2 instance. When you use this option, Auto Scaling copies the attributes from the specified instance into a template from which you can launch one or more Auto Scaling groups.

Tip

You can create an Auto Scaling group directly from an EC2 instance. When you use this feature, Auto Scaling automatically creates a launch configuration for you as well.

If the specified instance has properties that are not currently supported by Auto Scaling, instances launched by Auto Scaling using the launch configuration created from the identified instance might not be identical to the identified instance.

There are differences between creating a launch configuration from scratch and creating a launch configuration from an existing EC2 instance. When you create a launch configuration from scratch, you specify the image ID, instance type, optional resources (such as storage devices), and optional settings (like monitoring). When you create a launch configuration from a running instance, by default Auto Scaling derives attributes for the launch configuration from the specified instance, plus the block device mapping for the AMI that the instance was launched from (ignoring any additional block devices that were added to the instance after launch).

When you create a launch configuration using a running instance, you can override the following attributes by specifying then as part of the same request: AMI, block devices, key pair, instance profile, instance type, kernel, monitoring, placement tenancy, ramdisk, security groups, Spot price, user data, whether the instance has a public IP address is associated, and whether the instance is EBS-optimized.

The following examples show you to create a launch configuration from an EC2 instance.

Create a Launch Configuration Using an EC2 Instance

To create a launch configuration using the attributes of an existing EC2 instance, specify the ID of the instance.

Important

The AMI used to launch the specified instance must still exist.

Create a Launch Configuration from an EC2 Instance Using the AWS Management Console

You can use the console to create a launch configuration and an Auto Scaling group from a running EC2 instance and add the instance to the new Auto Scaling group. For more information, see Attach EC2 Instances to Your Auto Scaling Group.

Create a Launch Configuration from an EC2 Instance Using the AWS CLI

Use the following create-launch-configuration command to create a launch configuration from an instance using the same attributes as the instance (other than any block devices added after launch, which are ignored):

Copy
aws autoscaling create-launch-configuration --launch-configuration-name my-lc-from-instance --instance-id i-a8e09d9c

You can use the following describe-launch-configurations command to describe the launch configuration and verify that its attributes match those of the instance:

Copy
aws autoscaling describe-launch-configurations --launch-configuration-names my-lc-from-instance

The following is an example response:

Copy
{ "LaunchConfigurations": [ { "UserData": null, "EbsOptimized": false, "LaunchConfigurationARN": "arn", "InstanceMonitoring": { "Enabled": false }, "ImageId": "ami-05355a6c", "CreatedTime": "2014-12-29T16:14:50.382Z", "BlockDeviceMappings": [], "KeyName": "my-key-pair", "SecurityGroups": [ "sg-8422d1eb" ], "LaunchConfigurationName": "my-lc-from-instance", "KernelId": "null", "RamdiskId": null, "InstanceType": "t1.micro", "AssociatePublicIpAddress": true } ] }

Create a Launch Configuration from an Instance and Override the Block Devices

By default, Auto Scaling uses the attributes from the EC2 instance you specify to create the launch configuration, except that the block devices come from the AMI used to launch the instance, not the instance. To add block devices to the launch configuration, override the block device mapping for the launch configuration.

Important

The AMI used to launch the specified instance must still exist.

Create a Launch Configuration and Override the Block Devices Using the AWS CLI

Use the following create-launch-configuration command to create a launch configuration using an EC2 instance but with a custom block device mapping:

Copy
aws autoscaling create-launch-configuration --launch-configuration-name my-lc-from-instance-bdm --instance-id i-a8e09d9c --block-device-mappings "[{\"DeviceName\":\"/dev/sda1\",\"Ebs\":{\"SnapshotId\":\"snap-3decf207\"}},{\"DeviceName\":\"/dev/sdf\",\"Ebs\":{\"SnapshotId\":\"snap-eed6ac86\"}}]"

Use the following describe-launch-configurations command to describe the launch configuration and verify that it uses your custom block device mapping:

Copy
aws autoscaling describe-launch-configurations --launch-configuration-names my-lc-from-instance-bdm

The following example response describes the launch configuration:

Copy
{ "LaunchConfigurations": [ { "UserData": null, "EbsOptimized": false, "LaunchConfigurationARN": "arn", "InstanceMonitoring": { "Enabled": false }, "ImageId": "ami-c49c0dac", "CreatedTime": "2015-01-07T14:51:26.065Z", "BlockDeviceMappings": [ { "DeviceName": "/dev/sda1", "Ebs": { "SnapshotId": "snap-3decf207" } }, { "DeviceName": "/dev/sdf", "Ebs": { "SnapshotId": "snap-eed6ac86" } } ], "KeyName": "my-key-pair", "SecurityGroups": [ "sg-8637d3e3" ], "LaunchConfigurationName": "my-lc-from-instance-bdm", "KernelId": null, "RamdiskId": null, "InstanceType": "t1.micro", "AssociatePublicIpAddress": true } ] }

Create a Launch Configuration and Override the Instance Type

By default, Auto Scaling uses the attributes from the EC2 instance you specify to create the launch configuration. Depending on your requirements, you might want to change some of these attributes. Auto Scaling provides you with options to override attributes from the instance and use the values that you need. For example, you can override the instance type.

Important

The AMI used to launch the specified instance must still exist.

Create a Launch Configuration and Override the Instance Type Using the AWS CLI

Use the following create-launch-configuration command to create a launch configuration using an EC2 instance but with a different instance type (for example m1.small) than the instance (for example t1.micro):

Copy
aws autoscaling create-launch-configuration --launch-configuration-name my-lc-from-instance-changetype --instance-id i-a8e09d9c --instance-type m1.small

Use the following describe-launch-configurations command to describe the launch configuration and verify that the instance type was overridden:

Copy
aws autoscaling describe-launch-configurations --launch-configuration-names my-lc-from-instance-changetype

The following example response describes the launch configuration:

Copy
{ "LaunchConfigurations": [ { "UserData": null, "EbsOptimized": false, "LaunchConfigurationARN": "arn", "InstanceMonitoring": { "Enabled": false }, "ImageId": "ami-05355a6c", "CreatedTime": "2014-12-29T16:14:50.382Z", "BlockDeviceMappings": [], "KeyName": "my-key-pair", "SecurityGroups": [ "sg-8422d1eb" ], "LaunchConfigurationName": "my-lc-from-instance-changetype", "KernelId": "null", "RamdiskId": null, "InstanceType": "m1.small", "AssociatePublicIpAddress": true } ] }