Menu
Amazon Elastic Compute Cloud
API Reference (API Version 2016-11-15)

CreateLaunchTemplate

Creates a launch template. A launch template contains the parameters to launch an instance. When you launch an instance using RunInstances, you can specify a launch template instead of providing the launch parameters in the request.

Request Parameters

The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.

ClientToken

Unique, case-sensitive identifier you provide to ensure the idempotency of the request. For more information, see Ensuring Idempotency.

Type: String

Required: No

DryRun

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Type: Boolean

Required: No

LaunchTemplateData

The information for the launch template.

Type: RequestLaunchTemplateData object

Required: Yes

LaunchTemplateName

A name for the launch template.

Type: String

Length Constraints: Minimum length of 3. Maximum length of 128.

Pattern: [a-zA-Z0-9\(\)\.-/_]+

Required: Yes

VersionDescription

A description for the first version of the launch template.

Type: String

Length Constraints: Maximum length of 255.

Required: No

Response Elements

The following elements are returned by the service.

launchTemplate

Information about the launch template.

Type: LaunchTemplate object

requestId

The ID of the request.

Type: String

Errors

For information about the errors that are common to all actions, see Common Client Errors.

Examples

Example 1

The following example creates a launch template that specifies AMI ami-1a2b3c4d and an instance type of t2.micro.

Sample Request

https://ec2.amazonaws.com/?Action=CreateLaunchTemplate
&LaunchTemplateName=MyLaunchTemplate
&VersionDescription=FirstVersion
&LaunchTemplateData.ImageId=ami-1a2b3c4d
&LaunchTemplateData.InstanceType=t2.micro
&AUTHPARAMS

Sample Response

<CreateLaunchTemplateResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
    <requestId>39f602bc-7580-4239-a6d8-af56example</requestId>
    <launchTemplate>
        <createTime>2017-10-31T11:38:52.000Z</createTime>
        <createdBy>arn:aws:iam::123456789012:root</createdBy>
        <defaultVersionNumber>1</defaultVersionNumber>
        <latestVersionNumber>1</latestVersionNumber>
        <launchTemplateId>lt-0a20c965061f64abc</launchTemplateId>
        <launchTemplateName>MyLaunchTemplate</launchTemplateName>
    </launchTemplate>
</CreateLaunchTemplateResponse>

Example 2

The following example creates a launch template that specifies the subnet in which to launch the instance (subnet-7b16de0c), assigns a public IP address and an IPv6 address to the instance, and creates a tag for the instance (Name=webserver).

Sample Request

https://ec2.amazonaws.com/?Action=CreateLaunchTemplate
&LaunchTemplateName=TemplateForWebServer
&VersionDescription=WebVersion1
&LaunchTemplateData.ImageId=ami-8c1be5f6
&LaunchTemplateData.InstanceType=t2.micro
&LaunchTemplateData.NetworkInterface.1.AssociatePublicIpAddress=true
&LaunchTemplateData.NetworkInterface.1.DeviceIndex=0
&LaunchTemplateData.NetworkInterface.1.SubnetId=subnet-7b16de0c
&LaunchTemplateData.NetworkInterface.1.Ipv6AddressCount=1
&LaunchTemplateData.TagSpecification.1.ResourceType=instance
&LaunchTemplateData.TagSpecification.1.Tag.1.Key=Name
&LaunchTemplateData.TagSpecification.1.Tag.1.Value=webserver
&AUTHPARAMS

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: