AWS CloudFormation
User Guide (Version )

AWS::AutoScaling::LaunchConfiguration

Specifies an Amazon EC2 Auto Scaling launch configuration that can be used by an Auto Scaling group to configure Amazon EC2 instances.

Important

When you update the launch configuration, AWS CloudFormation deletes that resource and creates a new launch configuration with the updated properties and a new name. This update action does not deploy any change across the running Amazon EC2 instances in the Auto Scaling group. In other words, after you associate a new launch configuration with an Auto Scaling group, all new instances will get the updated configuration, but existing instances continue to run with the configuration that they were originally launched with. This works the same way as any other Auto Scaling group that uses a launch configuration.

If you want to update existing instances when you update the LaunchConfiguration resource, you must specify an UpdatePolicy attribute for the Auto Scaling group. You can find sample update policies for rolling updates in the Examples section of the AWS::AutoScaling::AutoScalingGroup documentation.

For more information, see CreateLaunchConfiguration in the Amazon EC2 Auto Scaling API Reference and Launch Configurations in the Amazon EC2 Auto Scaling User Guide.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::AutoScaling::LaunchConfiguration", "Properties" : { "AssociatePublicIpAddress" : Boolean, "BlockDeviceMappings" : [ BlockDeviceMapping, ... ], "ClassicLinkVPCId" : String, "ClassicLinkVPCSecurityGroups" : [ String, ... ], "EbsOptimized" : Boolean, "IamInstanceProfile" : String, "ImageId" : String, "InstanceId" : String, "InstanceMonitoring" : Boolean, "InstanceType" : String, "KernelId" : String, "KeyName" : String, "LaunchConfigurationName" : String, "PlacementTenancy" : String, "RamDiskId" : String, "SecurityGroups" : [ String, ... ], "SpotPrice" : String, "UserData" : String } }

YAML

Type: AWS::AutoScaling::LaunchConfiguration Properties: AssociatePublicIpAddress: Boolean BlockDeviceMappings: - BlockDeviceMapping ClassicLinkVPCId: String ClassicLinkVPCSecurityGroups: - String EbsOptimized: Boolean IamInstanceProfile: String ImageId: String InstanceId: String InstanceMonitoring: Boolean InstanceType: String KernelId: String KeyName: String LaunchConfigurationName: String PlacementTenancy: String RamDiskId: String SecurityGroups: - String SpotPrice: String UserData: String

Properties

AssociatePublicIpAddress

Used for groups that launch instances into a virtual private cloud (VPC). Specifies whether to assign a public IP address to each instance. If you specify true, each instance in the Auto Scaling group receives a unique public IP address.

For more information, see Launching Auto Scaling Instances in a VPC in the Amazon EC2 Auto Scaling User Guide.

Default: If the instance is launched into a default subnet, the default is to assign a public IP address. If the instance is launched into a nondefault subnet, the default is not to assign a public IP address.

Note

If this resource has a public IP address and is also in a VPC that is defined in the same template, you must use the DependsOn attribute to declare a dependency on the VPC-gateway attachment.

Required: No

Type: Boolean

Update requires: Replacement

BlockDeviceMappings

Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.

Required: No

Type: List of BlockDeviceMapping

Update requires: Replacement

ClassicLinkVPCId

The ID of a ClassicLink-enabled VPC to link your EC2-Classic instances to.

For more information, see ClassicLink in the Amazon EC2 User Guide for Linux Instances and Linking EC2-Classic Instances to a VPC in the Amazon EC2 Auto Scaling User Guide.

This property can only be used if you are launching EC2-Classic instances.

Required: No

Type: String

Minimum: 1

Maximum: 255

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

ClassicLinkVPCSecurityGroups

The IDs of one or more security groups for the VPC that you specified in the ClassicLinkVPCId property.

If you specify the ClassicLinkVPCId property, you must specify this property.

Required: Conditional

Type: List of String

Update requires: Replacement

EbsOptimized

Specifies whether the launch configuration is optimized for EBS I/O (true) or not (false). This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal EBS I/O performance. Additional fees are incurred when you enable EBS optimization for an instance type that is not EBS-optimized by default. For more information, see EBS-Optimized Instances in the Amazon EC2 User Guide for Linux Instances.

The default value is false.

Required: No

Type: Boolean

Update requires: Replacement

IamInstanceProfile

Provides the name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance. The instance profile contains the IAM role.

For more information, see IAM Role for Applications that Run on Amazon EC2 Instances in the Amazon EC2 Auto Scaling User Guide.

Required: No

Type: String

Minimum: 1

Maximum: 1600

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

ImageId

Provides the unique ID of the Amazon Machine Image (AMI) that was assigned during registration. For more information, see Finding an AMI in the Amazon EC2 User Guide for Linux Instances.

Required: Yes

Type: String

Minimum: 1

Maximum: 255

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

InstanceId

The ID of the Amazon EC2 instance you want to use to create the launch configuration. Use this property if you want the launch configuration to use settings from an existing Amazon EC2 instance.

When you use an instance to create a launch configuration, all properties are derived from the instance with the exception of BlockDeviceMapping and AssociatePublicIpAddress. You can override any properties from the instance by specifying them in the launch configuration.

Required: No

Type: String

Update requires: Replacement

InstanceMonitoring

Controls whether instances in this group are launched with detailed (true) or basic (false) monitoring. The default value is true (enabled).

Important

When detailed monitoring is enabled, Amazon CloudWatch generates metrics every minute and your account is charged a fee. When you disable detailed monitoring, CloudWatch generates metrics every 5 minutes. For more information, see Configure Monitoring for Auto Scaling Instances in the Amazon EC2 Auto Scaling User Guide.

Required: No

Type: Boolean

Update requires: Replacement

InstanceType

Specifies the instance type of the EC2 instance. For information about available instance types, see Available Instance Types in the Amazon EC2 User Guide for Linux Instances.

Required: Yes

Type: String

Minimum: 1

Maximum: 255

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

KernelId

Provides the ID of the kernel associated with the EC2 AMI.

Note

We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see User Provided Kernels in the Amazon EC2 User Guide for Linux Instances.

Required: No

Type: String

Minimum: 1

Maximum: 255

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

KeyName

Provides the name of the EC2 key pair.

Important

If you do not specify a key pair, you can't connect to the instance unless you choose an AMI that is configured to allow users another way to log in. For information on creating a key pair, see Amazon EC2 Key Pairs in the Amazon EC2 User Guide for Linux Instances.

Required: No

Type: String

Minimum: 1

Maximum: 255

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

LaunchConfigurationName

The name of the launch configuration. This name must be unique per Region per account.

Required: No

Type: String

Minimum: 1

Maximum: 255

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

PlacementTenancy

The tenancy of the instance, either default or dedicated. An instance with dedicated tenancy runs in an isolated, single-tenant hardware and can only be launched into a VPC. You must set the value of this property to dedicated if want to launch dedicated instances in a shared tenancy VPC (a VPC with the instance placement tenancy attribute set to default).

If you specify this property, you must specify at least one subnet in the VPCZoneIdentifier property of the AutoScalingGroup resource.

For more information, see Instance Placement Tenancy in the Amazon EC2 Auto Scaling User Guide.

Required: No

Type: String

Minimum: 1

Maximum: 64

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

RamDiskId

The ID of the RAM disk to select.

Note

We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see User Provided Kernels in the Amazon EC2 User Guide for Linux Instances.

Required: No

Type: String

Minimum: 1

Maximum: 255

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

SecurityGroups

A list that contains the security groups to assign to the instances in the Auto Scaling group. The list can contain the IDs of existing security groups or references to SecurityGroup resources created in the template.

For more information, see Security Groups for Your VPC in the Amazon Virtual Private Cloud User Guide.

Required: No

Type: List of String

Update requires: Replacement

SpotPrice

The maximum hourly price to be paid for any Spot Instance launched to fulfill the request. Spot Instances are launched when the price you specify exceeds the current Spot market price. For more information, see Launching Spot Instances in your Auto Scaling Group in the Amazon EC2 Auto Scaling User Guide.

If a Spot price is set, then the Auto Scaling group will only launch when the Spot price has been met, regardless of the setting in the Auto Scaling group's DesiredCapacity.

Note

When you change your Spot price by creating a new launch configuration, running instances will continue to run as long as the Spot price for those running instances is higher than the current Spot market price.

Required: No

Type: String

Minimum: 1

Maximum: 255

Update requires: Replacement

UserData

The user data available to the launched EC2 instances.

For more information, see Instance Metadata and User Data in the Amazon EC2 User Guide for Linux Instances.

Required: No

Type: String

Maximum: 21847

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Update requires: Replacement

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the resource name. For example: mystack-mylaunchconfig-1DDYF1E3B3I.

For more information about using the Ref function, see Ref.

Examples

The following examples create launch configurations that can be used by an Auto Scaling group to configure Amazon EC2 instances.

Launch Configuration with Block Device Mappings

This example shows a launch configuration with a BlockDeviceMappings property that lists two devices: a 50 gigabyte EBS root volume mapped to /dev/sda1 and a 100 gigabyte EBS volume mapped to /dev/sdm. The /dev/sdm volume uses the default EBS volume type based on the region and is not deleted when terminating the instance it is attached to.

JSON

{ "myLaunchConfig":{ "Type":"AWS::AutoScaling::LaunchConfiguration", "Properties":{ "KeyName":{ "Ref":"KeyName" }, "ImageId":{ "Fn::FindInMap":[ "AWSRegionArch2AMI", { "Ref":"AWS::Region" }, { "Fn::FindInMap":[ "AWSInstanceType2Arch", { "Ref":"InstanceType" }, "Arch" ] } ] }, "UserData":{ "Fn::Base64":{ "Ref":"WebServerPort" } }, "SecurityGroups":[ { "Ref":"InstanceSecurityGroup" } ], "InstanceType":{ "Ref":"InstanceType" }, "BlockDeviceMappings":[ { "DeviceName":"/dev/sda1", "Ebs":{ "VolumeSize":"50", "VolumeType":"io1", "Iops":200 } }, { "DeviceName":"/dev/sdm", "Ebs":{ "VolumeSize":"100", "DeleteOnTermination":"false" } } ] } } }

YAML

myLaunchConfig: Type: AWS::AutoScaling::LaunchConfiguration Properties: KeyName: Ref: "KeyName" ImageId: Fn::FindInMap: - "AWSRegionArch2AMI" - Ref: "AWS::Region" - Fn::FindInMap: - "AWSInstanceType2Arch" - Ref: "InstanceType" - "Arch" UserData: Fn::Base64: Ref: "WebServerPort" SecurityGroups: - Ref: "InstanceSecurityGroup" InstanceType: Ref: "InstanceType" BlockDeviceMappings: - DeviceName: "/dev/sda1" Ebs: VolumeSize: "50" VolumeType: "io1" Iops: 200 - DeviceName: "/dev/sdm" Ebs: VolumeSize: "100" DeleteOnTermination: "false"

Launch Configuration with Spot Price

This example shows a launch configuration that launches Spot Instances in the Auto Scaling group. This launch configuration will only be active if the current Spot market price is less than the price in the template specification (0.05).

JSON

{ "myLaunchConfig":{ "Type":"AWS::AutoScaling::LaunchConfiguration", "Properties":{ "KeyName":{ "Ref":"KeyName" }, "ImageId":{ "Fn::FindInMap":[ "AWSRegionArch2AMI", { "Ref":"AWS::Region" }, { "Fn::FindInMap":[ "AWSInstanceType2Arch", { "Ref":"InstanceType" }, "Arch" ] } ] }, "SecurityGroups":[ { "Ref":"InstanceSecurityGroup" } ], "SpotPrice":"0.05", "InstanceType":{ "Ref":"InstanceType" } } } }

YAML

myLaunchConfig: Type: AWS::AutoScaling::LaunchConfiguration Properties: KeyName: Ref: "KeyName" ImageId: Fn::FindInMap: - "AWSRegionArch2AMI" - Ref: "AWS::Region" - Fn::FindInMap: - "AWSInstanceType2Arch" - Ref: "InstanceType" - "Arch" SecurityGroups: - Ref: "InstanceSecurityGroup" SpotPrice: "0.05" InstanceType: Ref: "InstanceType"

Launch Configuration with IAM Instance Profile

This example demonstrates a launch configuration that uses the IamInstanceProfile property. Only the AWS::AutoScaling::LaunchConfiguration specification is shown. For an example of the full template, including the definition of, and further references from the InstanceProfile object referenced here as RootInstanceProfile, see auto_scaling_with_instance_profile.template.

JSON

{ "myLaunchConfig":{ "Type":"AWS::AutoScaling::LaunchConfiguration", "Properties":{ "ImageId":{ "Fn::FindInMap":[ "AWSRegionArch2AMI", { "Ref":"AWS::Region" }, { "Fn::FindInMap":[ "AWSInstanceType2Arch", { "Ref":"InstanceType" }, "Arch" ] } ] }, "InstanceType":{ "Ref":"InstanceType" }, "IamInstanceProfile":{ "Ref":"RootInstanceProfile" } } } }

YAML

myLaunchConfig: Type: AWS::AutoScaling::LaunchConfiguration Properties: ImageId: Fn::FindInMap: - "AWSRegionArch2AMI" - Ref: "AWS::Region" - Fn::FindInMap: - "AWSInstanceType2Arch" - Ref: "InstanceType" - "Arch" InstanceType: Ref: "InstanceType" IamInstanceProfile: Ref: "RootInstanceProfile"

Launch Configuration with a Provisioned IOPS EBS Volume

This example demonstrates a launch configuration that configures the EbsOptmized property to launch instances with a provisioned IOPS EBS-optimized volume. This can increase the performance of your EBS-backed instances.

Note

For instances that are not EBS–optimized by default, you must enable EBS optimization to achieve the level of performance described in the Amazon EBS-Optimized Instances documentation in the Amazon Elastic Compute Cloud User Guide. For current generation instance types, EBS-optimization is enabled by default at no additional cost. Enabling EBS optimization for a previous generation instance type that is not EBS-optimized by default incurs additional fees.

When you use a launch configuration such as this one, your m1.large instances will contain optimized EBS root volumes with the provisioned IOPS settings that you specified in the AMI. Because you cannot specify the IOPS settings in a launch configuration, the AMI must be configured with a block device mapping that specifies the desired number of IOPS. The following are key attributes of this EBS-optimized instance configuration:

  • An instance type of m1.large or greater. This is required for EBS optimization. This optimization is only available for certain instance types and sizes.

  • An EBS-backed AMI with a volume type of io1 and the number of IOPS you want to provision for the volume.

  • The size of the EBS volume must accommodate the IOPS you need. There is a 50:1 ratio between IOPS and Gibibytes (GiB) of storage.

For more information about IOPS performance with provisioned IOPS volumes, see Provisioned IOPS SSD (io1) Volumes in the Amazon Elastic Compute Cloud User Guide.

For more performance tips, see Amazon EBS Volume Performance on Linux Instances in the Amazon Elastic Compute Cloud User Guide.

JSON

{ "myLaunchConfig":{ "Type":"AWS::AutoScaling::LaunchConfiguration", "Properties":{ "KeyName":{ "Ref":"KeyName" }, "ImageId":"ami-7430ba44", "UserData":{ "Fn::Base64":{ "Ref":"WebServerPort" } }, "SecurityGroups":[ { "Ref":"InstanceSecurityGroup" } ], "InstanceType":"m1.large", "EbsOptimized":"true" } } }

YAML

myLaunchConfig: Type: AWS::AutoScaling::LaunchConfiguration Properties: KeyName: Ref: "KeyName" ImageId: "ami-7430ba44" UserData: Fn::Base64: Ref: "WebServerPort" SecurityGroups: - Ref: "InstanceSecurityGroup" InstanceType: "m1.large" EbsOptimized: "true"