CreateLaunchTemplate

更新时间:
复制 MD 格式

Create an ECS instance launch template, abbreviated as a template. An instance launch template eliminates the need to enter numerous configuration parameters each time you create an instance.

Operation description

After you invoke CreateLaunchTemplate to create a template, Alibaba Cloud automatically generates a default version of the template with version number 1. You can subsequently create multiple versions based on this template by calling CreateLaunchTemplateVersion. Version numbers start from 1 and increment sequentially. If you do not specify a template version when creating an instance (RunInstances), the default version is used.

A launch template version includes configurations required for instance creation, such as the Region, image ID, instance type, security group ID, and Internet bandwidth. If a particular configuration is not specified in the template version, you must provide it explicitly when creating the instance.

When invoking this API, note the following:

  • Each account can create up to 30 launch templates per Region, and each template can have up to 30 versions.

  • Most parameters in a launch template are optional. Alibaba Cloud does not validate the existence or validity of parameter values when you create the template. Validation occurs only when you actually create an instance.

  • If a configuration is set in the launch template, you cannot omit it when creating an instance (RunInstances). For example, if the template sets HostName=LocalHost, and you leave HostName empty in RunInstances, the instance hostname will still be LocalHost. To overwrite the HostName=LocalHost setting, specify a different value such as HostName=MyHost 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 ID of the region in which to create the launch template. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

TemplateTag

array<object>

No

The tags to add to the launch template.

Note

You can add tags to or query the tags of launch templates by calling API operations. You cannot add tags to or query the tags of launch templates in the ECS console.

object

No

Tag N to add to the launch template.

Key

string

No

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

TestKey

Value

string

No

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

TestValue

RegionId

string

Yes

The ID of the region in which to create the launch template. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

LaunchTemplateName

string

Yes

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

testLaunchTemplateName

VersionDescription

string

No

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

testVersionDescription

ImageId

string

No

The ID of the image to use to create the instance. You can call the DescribeImages operation to query available images.

win2008r2_64_ent_sp1_en-us_40G_alibase_20170915.vhd

ImageOwnerAlias

string

No

The source of the image. Valid values:

  • system: public image provided by Alibaba Cloud.

  • self: custom image that you created.

  • others: shared image from another Alibaba Cloud account.

  • marketplace:Alibaba Cloud Marketplace image. If Alibaba Cloud Marketplace images are available, you can use the images without the need to subscribe to the images. Take note of the billing details of Alibaba Cloud Marketplace images.

system

PasswordInherit

boolean

No

Specifies whether to use the preset password of the image.

Note

If you set the PasswordInherit parameter to true, make sure that you leave the Password parameter empty and the selected image has a preset password.

false

InstanceType

string

No

The instance type of the instance. For more information, see Instance families. Alternatively, you can call the DescribeInstanceTypes operation to query the most recent instance type list.

ecs.g5.large

SecurityGroupId

string

No

The ID of the security group to which to assign the instance. Instances in the same security group can communicate with each other. A security group can contain up to 1,000 instances.

Note

You cannot specify both the SecurityGroupId and SecurityGroupIds.N parameters.

sg-bp15ed6xe1yxeycg****

VpcId

string

No

The ID of the virtual private cloud (VPC).

vpc-bp12433upq1y5scen****

VSwitchId

string

No

The ID of the vSwitch to which to connect the instance. This parameter is required if you specify the VpcId parameter.

vsw-bp1s5fnvk4gn2tws0****

InstanceName

string

No

The instance name. The name must be 2 to 128 characters in length and can contain letters, digits, colons (:), underscores (_), periods (.), and hyphens (-). The default value of this parameter is the InstanceId value.

When you create multiple ECS instances at a time, you can batch configure sequential names for the instances. The instance names can contain square brackets ([]) and commas (,). For more information, see Batch configure sequential names or hostnames for multiple instances.

k8s-node-[1,4]-alibabacloud

Description

string

No

The instance description. The description must be 2 to 256 characters in length and 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, the valid values of this parameter are 1 to 10 and the default value is 10.

  • When the purchased outbound public bandwidth is greater than 10 Mbit/s, the valid values of this parameter are 1 to the InternetMaxBandwidthOut value and the default value is the InternetMaxBandwidthOut value.

10

InternetMaxBandwidthOut

integer

No

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

10

HostName

string

No

The instance hostname.

  • The hostname cannot start or end with a period (.) or 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 (.) or contain only digits. It can contain letters, digits, and hyphens (-).

  • For instances that run other operating systems such as Linux, the hostname must be 2 to 64 characters in length. You can use periods (.) to separate the hostname into multiple segments. Each segment can contain letters, digits, and hyphens (-).

testHostName

ZoneId

string

No

The ID of the zone in which to create 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: Enterprise SSD (ESSD). You can use SystemDisk.PerformanceLevel to set the performance level of the ESSD to use as the system disk.

  • cloud_auto: ESSD AutoPL disk.

  • cloud_essd_entry: ESSD Entry disk.

For non-I/O optimized instances of retired instance types, the default value is cloud. For other types of instances, the default value is cloud_efficiency.

cloud_ssd

SystemDisk.Size

integer

No

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

  • Valid values if you set SystemDisk.Category to cloud: 20 to 500.

  • Valid values if you set SystemDisk.Category to other disk categories: 20 to 2048.

The value of this parameter must be at least 20 and greater than or equal to the size of the image.

40

SystemDisk.DiskName

string

No

The name of the system disk. The name must be 2 to 128 characters in length. The name must start with a letter and cannot start with http:// or https://. The name can contain letters, 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 cannot start with http:// or https://.

testSystemDiskDescription

SystemDisk.Iops

integer

No

Note

This parameter is in invitational preview and is unavailable for general users.

null

SystemDisk.PerformanceLevel

string

No

The performance level of the ESSD to use as the system disk. Default value: PL0. Valid values:

  • PL0: 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 information about ESSD performance levels, see ESSDs.

PL0

SystemDisk.DeleteWithInstance

boolean

No

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

  • true

  • false

Default value: true.

true

SystemDisk.AutoSnapshotPolicyId

string

No

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

sp-gc7c37d4ylw7mtnk****

SystemDisk.ProvisionedIops

integer

No

The provisioned read/write IOPS of the ESSD AutoPL disk to use as the system disk. Valid values: 0 to min{50,000, 1,000 × Capacity - Baseline IOPS}

Baseline IOPS = min{1,800 + 50 × Capacity, 50,000}

Note

This parameter is available only if you set the SystemDisk.Category parameter to cloud_auto. For more information, see ESSD AutoPL disks and Modify the performance configurations of an ESSD AutoPL disk.

50000

SystemDisk.BurstingEnabled

boolean

No

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

  • true

  • false

true

IoOptimized

string

No

Specifies whether to create an I/O optimized instance. Valid values:

  • none: creates a non-I/O optimized instance.

  • optimized: creates an I/O optimized instance.

optimized

InstanceChargeType

string

No

The billing method of the instance. Valid values:

  • PrePaid: subscription. If you set this parameter to PrePaid, make sure that your account has sufficient credits.Otherwise, an InvalidPayMethod error is returned.

  • PostPaid: pay-as-you-go.

PrePaid

Period

integer

No

The subscription duration 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

When the pay-by-traffic billing method for network usage is used, the maximum inbound and outbound bandwidths are used as the upper limits of bandwidths instead of guaranteed performance specifications. In scenarios where demand outstrips resource supplies, these maximum bandwidths may be limited. If you want guaranteed bandwidths for your instance, use the pay-by-bandwidth billing method for network usage.

PayByTraffic

EnableVmOsConfig

boolean

No

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

Note

This parameter will be removed in the future. To ensure future compatibility, we recommend that you use other parameters.

false

NetworkType

string

No

The network type of the instance. Valid values:

  • classic: classic network

  • vpc: VPC

vpc

UserData

string

No

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

ZWNobyBoZWxsbyBlY3Mh

KeyPairName

string

No

The name of the key pair. This parameter is empty by default.

  • For Windows instances, this parameter is ignored The Password parameter takes effect even if the KeyPairName parameter is specified.

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

testKeyPairName

RamRoleName

string

No

The name of the instance Resource Access Management (RAM) role. You can call the ListRoles operation provided by RAM to query the instance RAM roles that you created.

testRamRoleName

AutoReleaseTime

string

No

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

  • If the value of ss is not 00, the time is automatically rounded down to the nearest minute based on the value of mm.

  • The specified time must be at least 30 minutes later than the current time.

  • The specified time can be at most three years later than the current time.

2018-01-01T12:05:00Z

SpotStrategy

string

No

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

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

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

  • SpotAsPriceGo: The instance is created as a spot instance for which the market price at the time of purchase is automatically used as the bidding price.

NoSpot

SpotPriceLimit

number

No

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

0.97

SpotDuration

integer

No

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

  • 1: After a spot instance is created, Alibaba Cloud ensures that the instance is not automatically released within 1 hour. After the 1-hour protection period ends, the system compares the bid price with the market price and checks the resource inventory to determine whether to retain or release the instance.

  • 0: After a spot instance is created, Alibaba Cloud does not ensure that the instance runs for 1 hour. The system compares the bid price with the market price and checks the resource inventory to determine whether to retain or release the instance.

Alibaba Cloud sends an ECS system event to notify you 5 minutes before the instance is released. Spot instances are billed by second. We recommend that you specify a protection period based on your business requirements.

Note

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

1

ResourceGroupId

string

No

The ID of the resource group to which to assign the instance, Elastic Block Storage (EBS) device, and elastic network interface (ENI).

rg-bp67acfmxazb4p****

TemplateResourceGroupId

string

No

The ID of the 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: does not enable security hardening. This value is applicable to all images.

Deactive

PrivateIpAddress

string

No

The private IP address to assign to the instance.

To assign a private IP address to an instance that resides in a VPC, make sure that the IP address is an idle IP address within the CIDR block of the vSwitch specified by the VSwitchId parameter.

10.1.**.**

DeploymentSetId

string

No

The ID of the deployment set to which to deploy the instance.

ds-bp1brhwhoqinyjd6****

Ipv6AddressCount

integer

No

The number of IPv6 addresses to randomly generate for the primary elastic network interface (ENI). Valid values: 1 to 10.

1

DataDisk

array<object>

No

The data disks.

object

No

Data disk N.

PerformanceLevel

string

No

The performance level of the ESSD to use as data disk N. The value of N must be the same as that in DataDisk.N.Category when DataDisk.N.Category is set to cloud_essd. Valid values:

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

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

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

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

For information about ESSD performance levels, see ESSDs.

PL1

Description

string

No

The description of data disk N. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

testDataDiskDescription

SnapshotId

string

No

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

Note

Use snapshots created on or after July 15, 2013. Otherwise, an error is returned and your 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:

  • Valid values if you set DataDisk.N.Category to cloud: 5 to 2000.

  • Valid values if you set DataDisk.N.Category to cloud_efficiency: 20 to 32768.

  • Valid values if you set DataDisk.N.Category to cloud_ssd: 20 to 32768.

  • Valid values if you set DataDisk.N.Category to cloud_essd: vary based on the value of DataDisk.N.PerformanceLevel.

    • Valid values if DataDisk.N.PerformanceLevel is set to PL0: 1 to 32768.

    • Valid values if DataDisk.N.PerformanceLevel is set to PL1: 20 to 32768.

    • Valid values if DataDisk.N.PerformanceLevel is set to PL2: 461 to 32768.

    • Valid values if you set DataDisk.N.PerformanceLevel to PL3: 1261 to 32768.

  • Valid values if you set DataDisk.N.Category to cloud_auto: 1 to 32768.

  • Valid values if you set DataDisk.N.Category to 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 SnapshotId.

2000

Device

string

No

The mount point of data disk N. The mount points are named based on the number of data disks:

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

  • From the 26th data disk on: /dev/xvd[aa-zz]. For example, the 26th data disk is named /dev/xvdaa, the 27th data disk is named /dev/xvdab, and so on.

Note

This parameter is applicable to scenarios in which a full image is used to create instances. A full image is an image that contains an operating system, application software, and business data. For these scenarios, you can set the parameter to the mount point of data disk N contained in the full image and modify DataDisk.N.Size and DataDisk.N.Category to change the category and size of data disk N created based on the image.

/dev/xvdb

DiskName

string

No

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

testDataDiskName

Category

string

No

The category of data disk N. Valid values:

  • cloud: basic disk

  • cloud_efficiency: utra disk

  • cloud_ssd: standard SSD

  • cloud_essd: ESSD

  • cloud_auto: ESSD AutoPL disk

  • cloud_essd_entry: ESSD Entry disk

For I/O optimized instances, the default value is cloud_efficiency. For non-I/O optimized instances, the default value is cloud.

cloud_ssd

DeleteWithInstance

boolean

No

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

  • true

  • false

Default value: true.

true

Encrypted

string

No

Specifies whether to encrypt data disk N.

false

AutoSnapshotPolicyId

string

No

The ID of the automatic snapshot policy to apply to data disk N.

sp-m5e7fa9ute44ssa****

ProvisionedIops

integer

No

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

Baseline IOPS = min{1,800 + 50 × Capacity, 50,000}.

Note

This parameter is available only if you set DiskCategory to cloud_auto. For more information, see ESSD AutoPL disks and Modify the performance configurations of an ESSD AutoPL disk.

50000

BurstingEnabled

boolean

No

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

  • true

  • false

true

KMSKeyId

string

No

The ID of the KMS key used for the data disk.

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

NetworkInterface

array<object>

No

The information of the ENIs.

object

No

The information of ENI N.

VSwitchId

string

No

The ID of the vSwitch to which to connect ENI N.

Take note of the following items:

  • Valid values of N: 1 and 2. If the value of N is 1, you can configure a primary or secondary ENI. If the value of N is 2, you must configure a primary ENI and a secondary ENI.

  • If you set NetworkInterface.N.InstanceType to Primary, you must specify this parameter. In this case, this parameter is equivalent to VSwitchId. You cannot specify both NetworkInterface.N.VSwitchId and VSwitchId in the same request.

  • If you set NetworkInterface.N.InstanceType to Secondary or leave NetworkInterface.N.InstanceType empty, you do not need to specify this parameter. The default value is the VSwitchId value.

vsw-bp1s5fnvk4gn2tws0****

NetworkInterfaceName

string

No

The name of ENI N.

Take note of the following items:

  • Valid values of N: 1 and 2. If the value of N is 1, you can configure a primary or secondary ENI. If the value of N is 2, you must configure a primary ENI and a secondary ENI.

  • If you set NetworkInterface.N.InstanceType 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 to assign ENI N.

Take note of the following items:

  • Valid values of N: 1 and 2. If the value of N is 1, you can configure a primary or secondary ENI. If the value of N is 2, you must configure a primary ENI and a secondary ENI.

  • If you set NetworkInterface.N.InstanceType to Primary, you must specify this parameter. In this case, this parameter is equivalent to SecurityGroupId, and you cannot specify SecurityGroupId, SecurityGroupIds.N, or NetworkInterface.N.SecurityGroupIds.N.

  • If you set NetworkInterface.N.InstanceType to Secondary or leave NetworkInterface.N.InstanceType empty, you do not need to specify this parameter. The default value is the ID of the security group to which to assign the instance.

sg-bp15ed6xe1yxeycg****

PrimaryIpAddress

string

No

The primary IP address to assign to ENI N.

Take note of the following items:

  • Valid values of N: 1 and 2.

    • If the value of N is 1, you can configure a primary or secondary ENI. If you specify this parameter, set Amount to a numeric value greater than 1, and set NetworkInterface.N.InstanceType to Primary, the specified number of instances are created and consecutive primary IP addresses starting from the specified IP address are assigned to the instances. In this case, you cannot attach secondary ENIs to the instances.

    • If the value of N is 2, you must configure a primary ENI and a secondary ENI. If you specify this parameter, set Amount to a numeric value greater than 1, and set NetworkInterface.N.InstanceType to Primary, you cannot set NetworkInterface.2.InstanceType to Secondary to attach a secondary ENI.

  • If you set NetworkInterface.N.InstanceType to Primary, this parameter is equivalent to PrivateIpAddress. You cannot specify both this parameter and PrivateIpAddress in the same request.

  • If you set NetworkInterface.N.InstanceType to Secondary or leave NetworkInterface.N.InstanceType empty, the specified primary IP address is assigned to the secondary ENI. The default value is an IP address that is randomly selected from within the CIDR block of the vSwitch to which to connect the secondary ENI.

Note

You can attach only a single secondary ENI when you create an instance. After the instance is created, you can call the CreateNetworkInterface and AttachNetworkInterface operations to attach more secondary ENIs.

192.168.**.**

SecurityGroupIds

array

No

The IDs of security groups to which to assign ENI N.

  • Valid values of the first N: 1 and 2. If the value of N is 1, you can configure a primary or secondary ENI. If the value of N is 2, you must configure a primary ENI and a secondary ENI.

  • The second N in this parameter indicates that one or more security group IDs can be specified. The valid values of N vary based on the maximum number of security groups to which an instance can belong. For more information, see the Security group limits section of the "Limits" topic.

Take note of the following items:

  • If you set NetworkInterface.N.InstanceType to Primary, you must specify this parameter or NetworkInterface.N.SecurityGroupId. In this case, this parameter is equivalent to SecurityGroupIds.N, and you cannot specify SecurityGroupId, SecurityGroupIds.N, or NetworkInterface.N.SecurityGroupId.

  • If you set NetworkInterface.N.InstanceType to Secondary or leave NetworkInterface.N.InstanceType empty, you do not need to specify this parameter. The default value is the ID of the security group to which to assign the instance.

sg-bp67acfmxazb4p****

string

No

The ID of security group N to which to assign ENI N.

  • Valid values of the first N: 1 and 2. If the value of N is 1, you can configure a primary or secondary ENI. If the value of N is 2, you must configure a primary ENI and a secondary ENI.

  • The second N in this parameter indicates that one or more security group IDs can be specified. The valid values of N vary based on the maximum number of security groups to which an instance can belong. For more information, see the Security group limits section of the "Limits" topic.

Take note of the following items:

  • If you set NetworkInterface.N.InstanceType to Primary, you must specify this parameter or NetworkInterface.N.SecurityGroupId. In this case, this parameter is equivalent to SecurityGroupIds.N, and you cannot specify SecurityGroupId, SecurityGroupIds.N, or NetworkInterface.N.SecurityGroupId.

  • If you set NetworkInterface.N.InstanceType to Secondary or leave NetworkInterface.N.InstanceType empty, you do not need to specify this parameter. The default value is the ID of the security group to which to assign the instance.

sg-bp67acfmxazb4p****

InstanceType

string

No

The type of ENI N. Valid values of N: 1 and 2. If the value of N is 1, you can configure a primary or secondary ENI. If the value of N is 2, you must configure a primary ENI and a secondary ENI.

Valid values:

  • Primary

  • Secondary

Default value: Secondary.

Secondary

NetworkInterfaceTrafficMode

string

No

The communication mode of the primary ENI. Valid values:

  • Standard: uses the TCP communication mode.

  • HighPerformance: uses the remote direct memory access (RDMA) communication mode with Elastic RDMA Interface (ERI) enabled.

Standard

DeleteOnRelease

boolean

No

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

  • true

  • false

Default value: true.

Note

This parameter takes effect only for secondary ENIs.

true

Tag

array<object>

No

The tags to add to the instance, disks, and primary ENI that are created from the launch template.

Scenario

If you created a launch template by calling the CreateLaunchTemplate operation and use the default version that is automatically generated for the launch template to create instances, the specified tags are automatically added to the created instances, disks, and primary ENIs. For more information about the default versions of launch templates, see [xxxx](url).

object

No

Tag N to add to the instance, disks, and primary ENI that are created from the launch template.

Key

string

No

The key of tag N to add to the instance, disks, and primary ENI that are created from the launch template. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot contain http:// or https://. The tag key cannot start with acs: or aliyun.

TestKey

Value

string

No

The value of tag N to add to the instance, disks, and primary ENI that are created from the launch template. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot contain http:// or https://.

TestValue

SecurityGroupIds

array

No

The IDs of the security groups to which to assign the instance. The valid values of N are based on the maximum number of security groups to which the instance can belong. For more information, see the "Security group limits" section in Limits.

Note

You cannot specify both the SecurityGroupId and SecurityGroupIds.N parameters.

sg-bp15ed6xe1yxeycg7****

string

No

The ID of security group N to which to assign the instance. The valid values of N are based on the maximum number of security groups to which the instance can belong. For more information, see the "Security group limits" section in Limits.

Note

You cannot specify both the SecurityGroupId and SecurityGroupIds.N parameters.

sg-bp15ed6xe1yxeycg7****

SystemDisk.Encrypted

string

No

Specifies whether to encrypt the system disk. Valid values:

  • true

  • false

Default value: false.

Note

If you create an instance in Hong Kong Zone D or Singapore Zone A, you cannot encrypt the system disk.

false

DeletionProtection

boolean

No

Specifies whether to enable release protection for the instance. This parameter specifies whether you can use the ECS console or call the DeleteInstance operation to release the instance. Valid values:

  • true

  • false

Default value: false.

Note

This parameter is applicable only to pay-as-you-go instances. The release protection feature can protect instances against manual releases, but not against automatic releases.

false

CreditSpecification

string

No

The performance mode of the burstable instance. Valid values:

Standard

AutoRenew

boolean

No

Specifies whether to enable auto-renewal. Valid values:

  • true

  • false

Default value: false.

Note

This parameter takes effect only if you set InstanceChargeType to PrePaid.

true

AutoRenewPeriod

integer

No

The auto-renewal period of the instance. 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 unit of the subscription period. Valid values:

Month (default)

Month

HttpEndpoint

string

No

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

  • enabled

  • disabled

Default value: enabled.

enabled

HttpTokens

string

No

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

  • optional: does not forcefully use the security hardening mode (IMDSv2).

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

Default value: optional.

optional

HttpPutResponseHopLimit

integer

No

Note

This parameter is not publicly available.

3

SystemDisk.KMSKeyId

string

No

The ID of the KMS key to use for the system disk.

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

ImageOptions

object

No

Details about the image options.

LoginAsNonRoot

boolean

No

Specifies whether the instance that uses the image supports logons of the ecs-user user. Valid values:

  • true

  • false

false

SecurityOptions

object

No

Security options.

TrustedSystemMode

string

No

The trusted system mode. Valid value: vTPM.

Currently, the following instance families support the trusted system mode:

  • g7, c7, r7.

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

When you create an ECS instance using one of the above instance families, you must configure this parameter as follows:

  • If you use Alibaba Cloud Trusted System, set this parameter to vTPM. This enables trusted validation through Alibaba Cloud Trusted System when the instance starts.

  • If you do not use Alibaba Cloud Trusted System, you can leave this parameter unset. However, note that if your ECS instance uses the Enclave confidential computing mode (SecurityOptions.ConfidentialComputingMode=Enclave), the trusted system will still be enabled automatically.

  • When creating a trusted ECS instance via OpenAPI, you can only use the RunInstances operation. The CreateInstance operation does not currently support setting the SecurityOptions.TrustedSystemMode parameter.

Note

If you specify an instance as a trusted instance during creation, you can only use images that support the trusted system when replacing its system disk.

For more information about the trusted system, see Function Overview of Trusted Features on Security-Enhanced Instances.

vTPM

Response elements

Element

Type

Description

Example

object

LaunchTemplateId

string

The ID of the launch template.

lt-m5eiaupmvm2op9d****

RequestId

string

The ID of the request.

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.
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.
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.