All Products
Search
Document Center

Elastic Compute Service:CreateLaunchTemplate

Last Updated:Oct 16, 2026

Creates an ECS instance launch template. A launch template eliminates the need to specify a large number of configuration parameters each time you create an instance.

Operation description

After you call CreateLaunchTemplate to create a launch template, a default version with the version number 1 is automatically generated. You can subsequently create multiple versions based on this template by calling CreateLaunchTemplateVersion. The version numbers increment sequentially starting from 1. If you do not specify a template version number when you create an instance by calling RunInstances, the default version is used.

A version of an instance launch template contains the configurations required to create an instance, such as the region, image ID, instance type, security group ID, and public bandwidth. If a specific instance configuration is not specified in the version, you must specify it when you create the instance.

When you call this operation, take note of the following items:

  • You can create up to 30 instance launch templates in a region for each account, and each template can have up to 30 versions.

  • Most parameters of an instance launch template are optional. When you create a template, Alibaba Cloud does not verify the existence or validity of the parameter values in the template. The validity of the parameter values is verified only when an instance is actually created.

  • If a configuration is set in the instance launch template, you cannot filter out this configuration when you create an instance by calling RunInstances. For example, if the template sets HostName=LocalHost and the HostName parameter in RunInstances is left empty, the hostname of the instance remains LocalHost. To override the HostName=LocalHost configuration, you can set HostName to MyHost or another value in RunInstances.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:CreateLaunchTemplate

create

*LaunchTemplate

acs:ecs:{#regionId}:{#accountId}:launchtemplate/*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

TemplateTag

array<object>

No

The tags of the launch template.

Note

You can only create and query the tags of launch templates by calling API operations. You cannot create or view the tags in the console.

object

No

The tags of the launch template.

Key

string

No

The tag key of the launch template. Valid values of N: 1 to 20. If you specify this parameter, it cannot be an empty string. The tag key can be up to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://.

TestKey

Value

string

No

The tag value of the launch template. Valid values of N: 1 to 20. If you specify this parameter, it can be an empty string. The tag value can be up to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://.

TestValue

LaunchTemplateName

string

Yes

The name of the instance launch template. The name must be 2 to 128 characters in length and can contain letters and Chinese characters. It must start with a letter or a Chinese character and cannot start with http:// or https://. It can contain digits, colons (:), underscores (_), and hyphens (-).

testLaunchTemplateName

VersionDescription

string

No

The description of the instance launch template version. The description must be 2 to 256 characters in length and can contain letters and Chinese characters. It cannot start with http:// or https://.

testVersionDescription

ImageId

string

No

The image ID. This is the image resource selected when the instance is started. You can call the DescribeImages operation to query the available image resources.

win2008r2_64_ent_sp1_en-us_40G_alibase_20170915.vhd

ImageOwnerAlias

string

No

The source of the image. Valid values:

  • system: public images provided by Alibaba Cloud.

  • self: custom images that you created.

  • others: shared images from other Alibaba Cloud accounts.

  • marketplace: images provided by Alibaba Cloud Marketplace. You can use the Alibaba Cloud Marketplace images that you queried without subscribing to them in advance. You must pay attention to the billing details of the Alibaba Cloud Marketplace images.

system

PasswordInherit

boolean

No

Specifies whether to use the preset password of the image.

Note

When you specify this parameter, leave Password empty and make sure that the selected image has a preset password.

false

InstanceType

string

No

The resource specifications of the instance. For more information, see Instance family. You can also invoke the DescribeInstanceTypes operation to obtain the most recent instance type list.

ecs.g5.large

SecurityGroupId

string

No

The ID of the security group to which the new instance belongs. Instances in the same security group can access each other. A security group can manage up to 1,000 instances.

Note

You cannot specify both SecurityGroupId and SecurityGroupIds.N at the same time.

sg-bp15ed6xe1yxeycg****

VpcId

string

No

The ID of the virtual private cloud (VPC).

vpc-bp12433upq1y5scen****

VSwitchId

string

No

The ID of the vSwitch. This parameter is required when you create a VPC instance.

vsw-bp1s5fnvk4gn2tws0****

InstanceName

string

No

The instance name. The name must be 2 to 128 characters in length and can contain characters in the Letter category of Unicode, including letters and digits. It can contain colons (:), underscores (_), periods (.), and hyphens (-). Default value: the InstanceId of the instance.

When you create multiple ECS instances, you can batch specify sequential instance names, which can contain square brackets ([]) and commas (,). For more information, see Batch specify sequential instance names or hostnames.

k8s-node-[1,4]-alibabacloud

Description

string

No

The instance description. The description must be 2 to 256 characters in length and can contain letters and Chinese characters. It cannot start with http:// or https://.

testECSDescription

InternetMaxBandwidthIn

integer

No

The maximum inbound public bandwidth. Unit: Mbit/s. Valid values:

  • When the purchased outbound public bandwidth is less than or equal to 10 Mbit/s: 1 to 10. Default value: 10.

  • When the purchased outbound public bandwidth is greater than 10 Mbit/s: 1 to the value of InternetMaxBandwidthOut. Default value: the value of InternetMaxBandwidthOut.

10

InternetMaxBandwidthOut

integer

No

The maximum outbound public bandwidth. Unit: Mbit/s. Valid values: 0 to 100.

10

HostName

string

No

The hostname of the Elastic Compute Service server.

  • The hostname cannot start or end with a period (.) or a hyphen (-). It cannot contain consecutive periods (.) or hyphens (-).

  • For Windows instances, the hostname must be 2 to 15 characters in length and cannot contain periods (.). It cannot contain only digits. It can contain uppercase and lowercase letters, digits, and hyphens (-).

  • For instances of other operating systems such as Linux, the hostname must be 2 to 64 characters in length. It can contain multiple segments separated by periods (.). Each segment can contain uppercase and lowercase letters, digits, and hyphens (-).

testHostName

ZoneId

string

No

The zone ID of the instance.

cn-hangzhou-g

SystemDisk.Category

string

No

The category of the system disk. Valid values:

  • cloud: basic disk.

  • cloud_efficiency: ultra disk.

  • cloud_ssd: standard SSD.

  • cloud_essd: ESSD. You can use the SystemDisk.PerformanceLevel parameter to set the performance level of the disk.

  • cloud_auto: ESSD AutoPL disk.

  • cloud_essd_entry: ESSD Entry disk.

Default value: cloud for retired instance types that are not I/O optimized instances, and cloud_efficiency for other instance types.

cloud_ssd

SystemDisk.Size

integer

No

The size of the system disk. Unit: GiB. Valid values:

  • cloud: 20 to 500.

  • Other disk categories: 20 to 2048.

The value of this parameter must be greater than or equal to max{20, ImageSize}.

40

SystemDisk.DiskName

string

No

The name of the system disk. The name must be 2 to 128 characters in length and can contain letters and Chinese characters. It must start with a letter or a Chinese character and cannot start with http:// or https://. It can contain digits, colons (:), underscores (_), and hyphens (-).

testSystemDiskName

SystemDisk.Description

string

No

The description of the system disk. The description must be 2 to 256 characters in length and can contain letters and Chinese characters. It cannot start with http:// or https://.

testSystemDiskDescription

SystemDisk.Iops

integer

No

Note

This parameter is in invitational preview and is not available.

null

SystemDisk.PerformanceLevel

string

No

The performance level of the ESSD used as the system disk. Valid values:

  • PL0 (default): A single ESSD can deliver up to 10,000 random read/write IOPS.

  • PL1: A single ESSD can deliver up to 50,000 random read/write IOPS.

  • PL2: A single ESSD can deliver up to 100,000 random read/write IOPS.

  • PL3: A single ESSD can deliver up to 1,000,000 random read/write IOPS.

For more details about how to select the performance level of an ESSD, see ESSD.

PL0

SystemDisk.DeleteWithInstance

boolean

No

Specifies whether to release the system disk when the instance is released. Valid values:

  • true: releases the system disk when the instance is released.

  • false: does not release the system disk when the instance is released.

Default value: true.

true

SystemDisk.AutoSnapshotPolicyId

string

No

The ID of the automatic snapshot policy applied to the system disk.

sp-gc7c37d4ylw7mtnk****

SystemDisk.ProvisionedIops

integer

No

The provisioned read/write IOPS of the ESSD AutoPL disk. Valid values: 0 to min{50000, 1000 × Capacity - Baseline performance}.

Baseline performance = min{1800 + 50 × Capacity, 50000}.

Note

This parameter is supported only when DiskCategory is set to cloud_auto. For more information, see ESSD AutoPL disks and Modify the provisioned information of an ESSD AutoPL disk.

50000

SystemDisk.BurstingEnabled

boolean

No

Specifies whether to enable the performance burst feature. Valid values:

  • true: enables the feature.

  • false: disables the feature.

true

IoOptimized

string

No

Specifies whether the instance is an I/O optimized instance. Valid values:

  • none: The instance is not I/O optimized.

  • optimized: The instance is I/O optimized.

optimized

InstanceChargeType

string

No

The billing method of the instance. Valid values:

  • PrePaid: subscription. If you select this billing method, you must confirm that your account supports credit payment. Otherwise, an InvalidPayMethod fault is returned.

  • PostPaid: pay-as-you-go.

PrePaid

Period

integer

No

The subscription period of the instance. Unit: months. This parameter is valid and required only when InstanceChargeType is set to PrePaid. Valid values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, and 60.

1

InternetChargeType

string

No

The billing method for network usage. Valid values:

  • PayByBandwidth: pay-by-bandwidth.

  • PayByTraffic: pay-by-traffic.

Note

In the pay-by-traffic pattern, the peak inbound and outbound bandwidths are used as upper limits of bandwidths instead of guaranteed performance specifications. In the event of resource contention, the peak bandwidths cannot be guaranteed. If your business requires guaranteed bandwidths, use the pay-by-bandwidth billing method.

PayByTraffic

EnableVmOsConfig

boolean

No

Specifies whether to enable the operating system configuration of the instance.

Note

This parameter will be deprecated. To improve compatibility, we recommend that you use other parameters.

false

NetworkType

string

No

The network type of the instance. Valid values:

  • classic: classic network. This network type is phased out. For more information, see Phasing-out notice.

  • vpc: VPC.

vpc

UserData

string

No

Instance user data of the instance. Instance user data must be encoded in Base64. The maximum size of the raw data is 32 KB.

ZWNobyBoZWxsbyBlY3Mh

KeyPairName

string

No

The name of the key pair.

  • For Windows instances, this parameter is ignored. Even if you specify this parameter, only the Password parameter takes effect.

  • For Linux instances, the password logon method is disabled by default.

testKeyPairName

RamRoleName

string

No

The name of the instance RAM role. You can call the ListRoles operation provided by RAM to query the instance RAM roles that you have created.

testRamRoleName

AutoReleaseTime

string

No

The automatic release time. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

  • If the ss value is not 00, the time is automatically rounded down to the current minute (mm).

  • The earliest release time is half an hour after the current time.

  • The latest release time cannot be more than three years after the current time. ISO 8601

2018-01-01T12:05:00Z

SpotStrategy

string

No

The preemption policy for the pay-as-you-go instance. This parameter takes effect only when InstanceChargeType is set to PostPaid. Valid values:

  • NoSpot: The instance is a regular pay-as-you-go instance.

  • SpotWithPriceLimit: The instance is a spot instance with a user-defined maximum hourly price.

  • SpotAsPriceGo: The instance is a spot instance for which the market price is automatically used as the bid price.

NoSpot

SpotPriceLimit

number

No

The maximum hourly price of the instance. The value can be accurate to three decimal places. This parameter takes effect only when SpotStrategy is set to SpotWithPriceLimit.

0.97

SpotDuration

integer

No

The protection period of the spot instance. Unit: hours. Default value: 1. Valid values:

  • 1: Alibaba Cloud guarantees that the instance is not subject to automatic release within 1 hour after it is created. After 1 hour, the system automatically compares the bid price with the marketplace price and checks resource inventory to determine whether to retain or revoke the instance.

  • 0: Alibaba Cloud does not guarantee that the instance is retained for 1 hour after it is created. The system automatically compares the bid price with the marketplace price and checks resource inventory to determine whether to retain or revoke the instance.

Alibaba Cloud sends you a notification by using an ECS system event 5 minutes before the instance is revoked. Spot instances use the billing method by second. We recommend that you select an appropriate protection period based on the execution duration of your tasks.

Note

This parameter takes effect only when SpotStrategy is set to SpotWithPriceLimit or SpotAsPriceGo.

1

ResourceGroupId

string

No

The ID of the enterprise resource group to which the instance, block storage, and elastic network interface (ENI) belong.

rg-bp67acfmxazb4p****

TemplateResourceGroupId

string

No

The ID of the enterprise resource group to which the launch template belongs.

rg-bp67acfmxazb4p****

SecurityEnhancementStrategy

string

No

Specifies whether to enable security hardening for the operating system. Valid values:

  • Active: enables security hardening. This value is applicable only to public images.

  • Deactive: disables security hardening. This value is applicable to all image types.

Deactive

PrivateIpAddress

string

No

The private IP address of the instance.

When you specify the private IP address for an ECS instance in a VPC, the IP address must be selected from the idle CIDR block of the vSwitch specified by VSwitchId.

10.1.**.**

DeploymentSetId

string

No

The ID of the deployment set.

ds-bp1brhwhoqinyjd6****

Ipv6AddressCount

integer

No

The number of IPv6 addresses to be randomly generated for the primary ENI. Valid values: 1 to 10.

1

DataDisk

array<object>

No

The list of data disks.

object

No

The list of data disks.

PerformanceLevel

string

No

The performance level of the ESSD used as the data disk. The value of N must be the same as the value of N in DataDisk.N.Category=cloud_essd. Valid values:

  • PL0: A single ESSD can deliver up to 10,000 random read/write IOPS.

  • PL1 (default): A single ESSD can deliver up to 50,000 random read/write IOPS.

  • PL2: A single ESSD can deliver up to 100,000 random read/write IOPS.

  • PL3: A single ESSD can deliver up to 1,000,000 random read/write IOPS.

For more details about how to select the performance level of an ESSD, see ESSD.

PL1

Description

string

No

The description of the data disk. The description must be 2 to 256 characters in length and can contain letters and Chinese characters. It cannot start with http:// or https://.

testDataDiskDescription

SnapshotId

string

No

The ID of the snapshot used to create data disk N. Valid values of N: 1 to 16. If you specify the DataDisk.N.SnapshotId parameter, the DataDisk.N.Size parameter is ignored. The actual size of the created disk is the size of the specified snapshot.

Note

You cannot use snapshots created on or before July 15, 2013. Otherwise, the request is rejected.

s-bp17441ohwka0yuh****

Size

integer

No

The size of data disk N. Valid values of N: 1 to 16. Unit: GiB. Valid values:

  • cloud: 5 to 2000.

  • cloud_efficiency: 20 to 32768.

  • cloud_ssd: 20 to 32768.

  • cloud_essd: The valid values are subject to the value of DataDisk.N.PerformanceLevel.
    • PL0: 1 to 32768.

    • PL1: 20 to 32768.

    • PL2: 461 to 32768.

    • PL3: 1261 to 32768.

  • cloud_auto: 1 to 32768.

  • cloud_essd_entry: 10 to 32768.

The value of this parameter must be greater than or equal to the size of the snapshot specified by the SnapshotId parameter.

2000

Device

string

No

The mount point of the data disk. The naming convention for mount points varies based on the number of attached data disks:

  • 1 to 25 data disks: /dev/xvd[b-z].

  • More than 25 data disks: /dev/xvd[aa-zz]. For example, the 26th data disk is named /dev/xvdaa, and the 27th data disk is named /dev/xvdab.

Note

This parameter is applicable only to full images. You can set this parameter to the mount point of the data disk in the full image and modify the DataDisk.N.Size and DataDisk.N.Category parameters to change the category and size of the data disk in the full image.

/dev/xvdb

DiskName

string

No

The name of the data disk. The name must be 2 to 128 characters in length and can contain letters and Chinese characters. It must start with a letter or a Chinese character and cannot start with http:// or https://. It can contain digits, colons (:), underscores (_), and hyphens (-).

testDataDiskName

Category

string

No

The category of data disk N. Valid values:

  • cloud_efficiency: ultra disk.

  • cloud_ssd: standard SSD.

  • cloud_essd: ESSD.

  • cloud: basic disk.

  • cloud_auto: ESSD AutoPL disk.

  • cloud_regional_disk_auto: regional ESSD.

  • cloud_essd_entry: ESSD Entry disk.
    Note

    This parameter can be set to cloud_essd_entry only when InstanceType is set to an instance type in the ecs.u1 or ecs.e instance family.

  • elastic_ephemeral_disk_standard: standard elastic ephemeral disk.

  • elastic_ephemeral_disk_premium: Premium Edition elastic ephemeral disk.

Default values: cloud_efficiency for I/O optimized instances, and cloud for non-I/O optimized instances. Default value description:

  • If the instance type is a retired and non-I/O optimized instance type, the default value is cloud.

  • In other cases, the default value is cloud_efficiency.

cloud_ssd

DeleteWithInstance

boolean

No

Specifies whether to release the data disk when the instance is released. Valid values:

  • true: releases the data disk when the instance is released.

  • false: does not release the data disk when the instance is released.

Default value: true.

true

Encrypted

string

No

Specifies whether to encrypt the data disk.

false

AutoSnapshotPolicyId

string

No

The ID of the automatic snapshot policy applied to the data disk.

sp-m5e7fa9ute44ssa****

ProvisionedIops

integer

No

The provisioned read/write IOPS of the ESSD AutoPL disk. Valid values: 0 to min{50000, 1000 × Capacity - Baseline performance}.

Baseline performance = min{1800 + 50 × Capacity, 50000}.

Note

This parameter is supported only when DiskCategory is set to cloud_auto. For more information, see ESSD AutoPL disks and Modify the provisioned information of an ESSD AutoPL disk.

50000

BurstingEnabled

boolean

No

Specifies whether to enable the performance burst feature. Valid values:

  • true: enables the feature.

  • false: disables the feature.

true

KMSKeyId

string

No

The ID of the Key Management Service (KMS) key used to encrypt the data disk.

0e478b7a-4262-4802-b8cb-00d****

NetworkInterface

array<object>

No

The Elastic Network Interface (ENI) information.

object

No

The Elastic Network Interface (ENI) information.

VSwitchId

string

No

The ID of the vSwitch to which the ENI belongs.

Note:

  • Valid values of N: 1 to 2. When you configure one ENI, you can configure one primary ENI or one secondary ENI. When you configure two ENIs, you can configure only one primary ENI and one secondary ENI at the same time.

  • If NetworkInterface.N.InstanceType is set to Primary, you must specify this parameter. In this case, this parameter serves the same purpose as VSwitchId, but you cannot specify both VSwitchId and this parameter at the same time.

  • If NetworkInterface.N.InstanceType is set to Secondary or left empty, this parameter is optional. The default value is the vSwitch to which the ECS instance belongs.

vsw-bp1s5fnvk4gn2tws0****

NetworkInterfaceName

string

No

The name of the ENI.

Note:

  • Valid values of N: 1 to 2. When you configure one ENI, you can configure one primary ENI or one secondary ENI. When you configure two ENIs, you can configure only one primary ENI and one secondary ENI at the same time.

  • If NetworkInterface.N.InstanceType is set to Primary, you do not need to specify this parameter.

testEniName

Description

string

No

The description of the secondary ENI. The description must be 2 to 256 characters in length and cannot start with http:// or https://. The value of N in NetworkInterface.N cannot be greater than 1.

testEniDescription

SecurityGroupId

string

No

The ID of the security group to which the ENI belongs.

Note:

  • Valid values of N: 1 to 2. When you configure one ENI, you can configure one primary ENI or one secondary ENI. When you configure two ENIs, you can configure only one primary ENI and one secondary ENI at the same time.

  • If NetworkInterface.N.InstanceType is set to Primary, you must specify this parameter. In this case, this parameter serves the same purpose as SecurityGroupId, but you cannot specify SecurityGroupId, SecurityGroupIds.N, or NetworkInterface.N.SecurityGroupIds.N at the same time.

  • If NetworkInterface.N.InstanceType is set to Secondary or left empty, this parameter is optional. The default value is the security group to which the ECS instance belongs.

sg-bp15ed6xe1yxeycg****

PrimaryIpAddress

string

No

Adds an ENI and configures the primary IP address.

Note:

  • Valid values of N: 1 to 2:

    • When you configure one ENI, you can configure one primary ENI or one secondary ENI. If the Amount parameter is set to a value greater than 1, and you configure a primary ENI and specify this parameter, consecutive primary IP addresses starting from the specified primary IP address are allocated to multiple ECS instances that are created in a batch. Note that you cannot bind secondary ENIs to the instances in this case.

    • When you configure two ENIs, you can configure only one primary ENI and one secondary ENI at the same time. Note that if the Amount parameter is set to a value greater than 1 and you specify this parameter for the primary ENI, you cannot configure a secondary ENI (that is, you cannot set NetworkInterface.2.InstanceType=Secondary).

  • If NetworkInterface.N.InstanceType is set to Primary, this parameter serves the same purpose as PrivateIpAddress, but you cannot specify both PrivateIpAddress and this parameter at the same time.

  • If NetworkInterface.N.InstanceType is set to Secondary or left empty, this parameter specifies the primary IP address for the secondary ENI. By default, an IP address is randomly selected from the vSwitch CIDR block to which the ENI belongs.

Note

When you create an ECS instance, you can add only one secondary ENI. After the instance is created, you can call the CreateNetworkInterface and AttachNetworkInterface operations to add more secondary ENIs.

192.168.**.**

SecurityGroupIds

array

No

The IDs of one or more security groups to which the ENI belongs.

  • The valid values of the first N are 1 to 2. When you configure one ENI, you can configure one primary ENI or one secondary ENI. When you configure two ENIs, you can configure only one primary ENI and one secondary ENI at the same time.

  • The second N specifies one or more security group IDs. The valid values of N depend on the quota of security groups to which an instance can be added. For more information, see Security group limits.

Note:

  • If NetworkInterface.N.InstanceType is set to Primary, you must specify this parameter or NetworkInterface.N.SecurityGroupId. In this case, this parameter serves the same purpose as SecurityGroupIds.N, but you cannot specify SecurityGroupId, SecurityGroupIds.N, or NetworkInterface.N.SecurityGroupId at the same time.

  • If NetworkInterface.N.InstanceType is set to Secondary or left empty, this parameter is optional. The default value is the security group to which the ECS instance belongs.

sg-bp67acfmxazb4p****

string

No

The IDs of one or more security groups to which the ENI belongs.

  • The valid values of the first N are 1 to 2. When you configure one ENI, you can configure one primary ENI or one secondary ENI. When you configure two ENIs, you can configure only one primary ENI and one secondary ENI at the same time.

  • The second N specifies one or more security group IDs. The valid values of N depend on the quota of security groups to which an instance can be added. For more information, see Security group limits.

Note:

  • If NetworkInterface.N.InstanceType is set to Primary, you must specify this parameter or NetworkInterface.N.SecurityGroupId. In this case, this parameter serves the same purpose as SecurityGroupIds.N, but you cannot specify SecurityGroupId, SecurityGroupIds.N, or NetworkInterface.N.SecurityGroupId at the same time.

  • If NetworkInterface.N.InstanceType is set to Secondary or left empty, this parameter is optional. The default value is the security group to which the ECS instance belongs.

sg-bp67acfmxazb4p****

InstanceType

string

No

The type of the ENI. Valid values of N: 1 to 2. When you configure one ENI, you can configure one primary ENI or one secondary ENI. When you configure two ENIs, you can configure only one primary ENI and one secondary ENI at the same time.

Valid values of the parameter:

  • Primary: primary ENI.

  • Secondary: secondary ENI.

Default value: Secondary.

Secondary

NetworkInterfaceTrafficMode

string

No

The communication mode of the primary ENI. Valid values:

  • Standard: uses the TCP communication mode.

  • HighPerformance: enables the Elastic RDMA Interface (ERI) and uses the RDMA communication mode.

Standard

DeleteOnRelease

boolean

No

Specifies whether to retain the ENI when the instance is released. Valid values:

  • true: does not retain the ENI.

  • false: retains the ENI.

Default value: true.

Note

This parameter takes effect only for secondary ENIs.

true

Tag

array<object>

No

The tag information of the instances, cloud disks, and primary ENIs that are created by using this version of the launch template.

Scenarios

After you call the CreateLaunchTemplate operation to create a launch template and use the automatically generated default version to create instances, this tag is used to tag the instances, cloud disks, and primary ENIs.

object

No

The tag information of the instances, cloud disks, and primary ENIs that are created by using this version of the launch template.

Key

string

No

The tag key of the instances, cloud disks, and primary ENIs that are created by using this version of the launch template. Valid values of N: 1 to 20. The tag key cannot be an empty string. It can be up to 128 characters in length and cannot start with aliyun or acs:. It cannot contain http:// or https://.

TestKey

Value

string

No

The tag value of the instances, cloud disks, and primary ENIs that are created by using this version of the launch template. Valid values of N: 1 to 20. The tag value can be an empty string. It can be up to 128 characters in length and cannot contain http:// or https://.

TestValue

SecurityGroupIds

array

No

The IDs of one or more security groups to which the instance is added. The valid values of N depend on the quota of security groups to which an instance can be added. For more information, see Limits.

Note

You cannot specify both SecurityGroupId and SecurityGroupIds.N.

sg-bp15ed6xe1yxeycg7****

string

No

The IDs of one or more security groups to which the instance is added. The valid values of N depend on the quota of security groups to which an instance can be added. For more information, see Limits.

Note

You cannot specify both SecurityGroupId and SecurityGroupIds.N.

sg-bp15ed6xe1yxeycg7****

SystemDisk.Encrypted

string

No

Specifies whether to encrypt the system disk. Valid values:

  • true: encrypts the system disk.

  • false: does not encrypt the system disk.

Default value: false.

Note

You cannot encrypt the system disk when you create an instance in Zone D of the Hong Kong (China) region or Zone A of the Singapore region.

false

DeletionProtection

boolean

No

The release protection property of the instance. It specifies whether the instance can be released by using the console or by calling the DeleteInstance operation. Valid values:

  • true: enables release protection for the instance.

  • false: disables release protection for the instance.

Default value: false.

Note

This property applies only to pay-as-you-go instances. It can prevent only manual release operations, but not system release operations.

false

CreditSpecification

string

No

The performance mode of the burstable instance. Valid values:

  • Standard: standard mode. For more information about the performance of the instance, see the "Standard mode" section in Overview of burstable instances.

  • Unlimited: unlimited mode. For more information about the performance of the instance, see the "Unlimited mode" section in Overview of burstable instances.

Standard

AutoRenew

boolean

No

Specifies whether to enable auto-renewal. Valid values:

  • true: enables auto-renewal.

  • false: disables auto-renewal.

Default value: false.

Note

This parameter takes effect only when the InstanceChargeType parameter is set to PrePaid.

true

AutoRenewPeriod

integer

No

The auto-renewal duration. Valid values:

Valid values when PeriodUnit is set to Month: 1, 2, 3, 6, 12, 24, 36, 48, and 60.

Default value: 1.

1

PeriodUnit

string

No

The time unit for the subscription Billable methods. Valid values:

Month (default).

Month

HttpEndpoint

string

No

Specifies whether to enable the access channel for instance metadata. Valid values:

  • enabled: enables the access channel.

  • disabled: disables the access channel.

Default value: enabled.

Note

For more information about instance metadata, see Overview of instance metadata.

enabled

HttpTokens

string

No

Specifies whether to forcibly use the security hardening mode (IMDSv2) to access instance metadata. Valid values:

  • optional: does not forcibly use the security hardening mode.

  • required: forcibly uses the security hardening mode. After you set this parameter to required, you cannot access instance metadata in normal mode.

Default value: optional.

Note

For more information about the modes of accessing instance metadata, see Overview of instance metadata.

optional

HttpPutResponseHopLimit

integer

No

Note

This parameter is not available.

3

SystemDisk.KMSKeyId

string

No

The KMS key ID of the system disk.

0e478b7a-4262-4802-b8cb-00d3fb40****

ImageOptions

object

No

The image-related property information.

LoginAsNonRoot

boolean

No

Specifies whether the instance that uses this image supports logon as the ecs-user user. Valid values:

  • true: yes.

  • false: no.

false

SecurityOptions

object

No

The security options.

TrustedSystemMode

string

No

The trusted system pattern. Valid value: vTPM.

Currently, the trusted system pattern supports the following instance families:

  • g7, c7, and r7.

  • security-enhanced instance families (g7t, c7t, and r7t).

When you create an ECS instance of the preceding instance families, you must configure this parameter. Details:

  • If you use the Alibaba Cloud trusted system, configure this parameter to vTPM. This way, the Alibaba Cloud trusted system performs trusted verification when the instance starts.

  • If you do not use the Alibaba Cloud trusted system, you can leave this parameter empty. However, if the ECS instance that you create uses the Enclave confidential computing pattern (SecurityOptions.ConfidentialComputingMode=Enclave), the trusted system is also enabled for the ECS instance.

  • When you create an ECS instance with the trusted system enabled by calling an API operation, you can only call the RunInstances operation. The CreateInstance operation does not support configuring the SecurityOptions.TrustedSystemMode parameter.

Note

If you specify an instance as a trusted instance when you create it, you can only use an image that supports the trusted system when you replace the system disk.

For more information about the trusted system, see Overview of the trusted feature for security-enhanced instance families.

vTPM

EnableSecureBoot

boolean

No

Specifies whether to enable secure boot.

Response elements

Element

Type

Description

Example

object

LaunchTemplateId

string

The ID of the launch template.

lt-m5eiaupmvm2op9d****

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

LaunchTemplateVersionNumber

integer

The version number of the launch template.

20

Examples

Success response

JSON format

{
  "LaunchTemplateId": "lt-m5eiaupmvm2op9d****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "LaunchTemplateVersionNumber": 20
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidRegion.NotExist %s The specified region does not exist.
400 MissingParameter %s A parameter is not specified.
400 InvalidParameter %s The specified parameter is invalid.
400 InvalidLaunchTemplateName.Malformed The specified parameter LaunchTemplateName is not valid. The specified LaunchTemplateName parameter is invalid.
400 InvalidDescription.Malformed The specified parameter "VersionDescription" is not valid.
400 InvalidUserData.SizeExceeded %s The size of your specified user data exceeds the maximum allowed value.
400 InvalidUserData.Base64FormatInvalid %s The specified user data is invalid.
400 Duplicate.TagKey The Tag.N.Key contain duplicate key. The specified tag key already exists. Tag keys must be unique.
400 InvalidTagKey.Malformed The specified Tag.n.Key is not valid. The specified Tag.N.Key parameter is invalid.
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. The specified tag value is invalid.
400 InvalidHostName.Malformed The specified parameter "HostName" is not valid. The specified HostName parameter is invalid.
400 InvalidParams.CreateEniParams %s
500 InternalError The request processing has failed due to some unknown error.
403 LaunchTemplateLimitExceed %s The maximum number of launch templates has been reached.
403 LaunchTemplateName.Duplicated %s The specified launch template name already exists.
403 QuotaExceed.Tags %s The number of specified tags exceeds the upper limit. %s is a variable. An error message is dynamically returned based on call conditions.
403 InvalidOperation.InstanceTypeSecureBootUnsupported The instance type does not support secure boot. The instance type does not support secure boot.
403 InvalidOperation.SecureBootRegionNotSupported Secure Boot is not available in the specified region. The current region does not support enabling Secure Boot.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The specified resource group does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.