CreateLaunchTemplateVersion - Amazon Elastic Compute Cloud

CreateLaunchTemplateVersion

Creates a new version of a launch template. You must specify an existing launch template, either by name or ID. You can determine whether the new version inherits parameters from a source version, and add or overwrite parameters as needed.

Launch template versions are numbered in the order in which they are created. You can't specify, change, or replace the numbering of launch template versions.

Launch templates are immutable; after you create a launch template, you can't modify it. Instead, you can create a new version of the launch template that includes the changes that you require.

For more information, see Modify a launch template (manage launch template versions) in the Amazon EC2 User Guide.

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.

Constraint: Maximum 128 ASCII characters.

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

LaunchTemplateId

The ID of the launch template.

You must specify either the launch template ID or the launch template name, but not both.

Type: String

Required: No

LaunchTemplateName

The name of the launch template.

You must specify either the launch template ID or the launch template name, but not both.

Type: String

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

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

Required: No

ResolveAlias

If true, and if a Systems Manager parameter is specified for ImageId, the AMI ID is displayed in the response for imageID. For more information, see Use a Systems Manager parameter instead of an AMI ID in the Amazon EC2 User Guide.

Default: false

Type: Boolean

Required: No

SourceVersion

The version of the launch template on which to base the new version. Snapshots applied to the block device mapping are ignored when creating a new version unless they are explicitly included.

If you specify this parameter, the new version inherits the launch parameters from the source version. If you specify additional launch parameters for the new version, they overwrite any corresponding launch parameters inherited from the source version.

If you omit this parameter, the new version contains only the launch parameters that you specify for the new version.

Type: String

Required: No

VersionDescription

A description for the version of the launch template.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 255.

Required: No

Response Elements

The following elements are returned by the service.

launchTemplateVersion

Information about the launch template version.

Type: LaunchTemplateVersion object

requestId

The ID of the request.

Type: String

warning

If the new version of the launch template contains parameters or parameter combinations that are not valid, an error code and an error message are returned for each issue that's found.

Type: ValidationWarning object

Errors

For information about the errors that are common to all actions, see Common client error codes.

Examples

Example

The following example creates a new launch template version for launch template MyLaunchTemplate and uses version 2 of the launch template as the base for the new version. The new launch template uses ami-aabbccdd. All other launch template data is inherited from the source version.

Sample Request

https://ec2.amazonaws.com/?Action=CreateLaunchTemplate &SourceVersion=2 &LaunchTemplateName=MyLaunchTemplate &VersionDescription=VersionWithNewAMI &LaunchTemplateData.ImageId=ami-aabbccdd &AUTHPARAMS

Sample Response

<CreateLaunchTemplateVersionResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>6657423a-2616-461a-9ce5-3c65example</requestId> <launchTemplateVersion> <createTime>2017-10-31T11:56:00.000Z</createTime> <createdBy>arn:aws:iam::123456789012:root</createdBy> <defaultVersion>false</defaultVersion> <launchTemplateData> <imageId>ami-aabbccdd</imageId> <instanceType>t2.micro</instanceType> </launchTemplateData> <launchTemplateId>lt-0a20c965061f6454a</launchTemplateId> <launchTemplateName>MyLaunchTemplate</launchTemplateName> <versionDescription>VersionWithNewAMI</versionDescription> <versionNumber>4</versionNumber> </launchTemplateVersion> </CreateLaunchTemplateVersionResponse>

See Also

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