Creates an ECS instance launch template. A launch template eliminates the need to configure a large number of parameters every time you create an instance.
Operation description
After you call CreateLaunchTemplate to create a template, a default version with version number 1 is automatically generated. You can then create multiple versions based on this template (CreateLaunchTemplateVersion), with version numbers incrementing sequentially from 1. If you do not specify a template version when creating instances (RunInstances), the default version is used.
A launch template version contains the configurations for creating instances, such as the region, image ID, instance type, security group ID, and public bandwidth. If a specific configuration is not specified in the version, you must specify it when you create instances.
When you call this operation, take note of the following items:
-
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. When you create a template, Alibaba Cloud does not verify the existence or validity of parameter values. The validity of parameter values is verified only when you create instances.
-
If a configuration is specified in the launch template, it cannot be filtered out when you create instances (RunInstances). For example, if the template specifies
HostName=LocalHostand theHostNamevalue is left empty inRunInstances, the hostname of the instance is stillLocalHost. To override theHostName=LocalHostconfiguration, setHostName=MyHostor another value inRunInstances.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:CreateLaunchTemplate |
create |
*LaunchTemplate
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID. You can call DescribeRegions to query the most recent region list. |
cn-hangzhou |
| TemplateTag |
array<object> |
No |
The tag key-value pairs of the launch template itself. Note
Currently, you can create and query tags for launch templates only by using API operations. The console does not support creating or viewing these tags. |
|
|
object |
No |
The tag key-value pairs of the launch template itself. |
||
| Key |
string |
No |
The tag key of 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 start with |
TestKey |
| Value |
string |
No |
The tag value of 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 start with |
TestValue |
| RegionId |
string |
Yes |
The region ID. You can call DescribeRegions 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. It must start with a letter and cannot start with |
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 |
testVersionDescription |
| ImageId |
string |
No |
The image ID. You can call DescribeImages to query available image resources. |
win2008r2_64_ent_sp1_en-us_40G_alibase_20170915.vhd |
| ImageOwnerAlias |
string |
No |
The source of the image. Valid values:
|
system |
| PasswordInherit |
boolean |
No |
Specifies whether to use the password preset in the image. Note
When you use this parameter, the Password parameter must be empty. Make sure that the image you use has a password configured. |
false |
| InstanceType |
string |
No |
The instance type. For more information, see Instance family. You can also invoke DescribeInstanceTypes to query the most recent instance type list. |
ecs.g5.large |
| SecurityGroupId |
string |
No |
The ID of the security group to which the instance belongs. 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 |
sg-bp15ed6xe1yxeycg**** |
| VpcId |
string |
No |
The ID of the virtual private cloud (VPC). |
vpc-bp12433upq1y5scen**** |
| VSwitchId |
string |
No |
The vSwitch ID. This parameter is required when you create a VPC-connected instance. |
vsw-bp1s5fnvk4gn2tws0**** |
| InstanceName |
string |
No |
The name of the instance. The name must be 2 to 128 characters in length and can contain letters, digits, and characters from the Unicode letter category (including Chinese characters). The name can contain colons (:), underscores (_), periods (.), and hyphens (-). The default value is the When you create multiple ECS instances, you can specify sequential instance names. The names can contain brackets ([]) and commas (,). For more information, see Specify sequential instance names or hostnames. |
k8s-node-[1,4]-alibabacloud |
| Description |
string |
No |
The description of the instance. The description must be 2 to 256 characters in length and cannot start with |
testECSDescription |
| InternetMaxBandwidthIn |
integer |
No |
The maximum inbound public bandwidth. Unit: Mbit/s. Valid values:
|
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.
|
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:
For retired instance types that are not I/O optimized, the default value is cloud. Otherwise, the default value is cloud_efficiency. |
cloud_ssd |
| SystemDisk.Size |
integer |
No |
The size of the system disk. Unit: GiB. Valid values:
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. It must start with a letter and cannot start with |
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 |
testSystemDiskDescription |
| SystemDisk.Iops |
integer |
No |
Note
This parameter is in invitational preview and is not publicly available. |
null |
| SystemDisk.PerformanceLevel |
string |
No |
The performance level of the ESSD used as the system disk. Valid values:
For information about how to select an ESSD performance level, see Enterprise SSDs. |
PL0 |
| SystemDisk.DeleteWithInstance |
boolean |
No |
Specifies whether to release the system disk when the instance is released. Valid values:
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{1,800 + 50 × Capacity, 50,000} Note
This parameter is supported only when DiskCategory is set to cloud_auto. For more information, see ESSD AutoPL disks and Modify the provisioned performance of an ESSD AutoPL disk. |
50000 |
| SystemDisk.BurstingEnabled |
boolean |
No |
Specifies whether to enable the performance burst feature. Valid values:
|
true |
| IoOptimized |
string |
No |
Specifies whether the instance is I/O optimized. Valid values:
|
optimized |
| InstanceChargeType |
string |
No |
The billing method of the instance. Valid values:
|
PrePaid |
| Period |
integer |
No |
The subscription duration of the resource. Unit: months. This parameter takes effect and is required only when |
1 |
| InternetChargeType |
string |
No |
The billing method for network usage. Valid values:
Note
In pay-by-traffic mode, the peak inbound and outbound bandwidths are used as bandwidth upper limits instead of guaranteed service metrics. When resource contention occurs, the peak bandwidth may be limited. If your workloads require guaranteed bandwidth, use the pay-by-bandwidth mode. |
PayByTraffic |
| EnableVmOsConfig |
boolean |
No |
Specifies whether to enable the operating system configuration of the instance. Note
This parameter will be deprecated. For better compatibility, use other parameters. |
false |
| NetworkType |
string |
No |
The network type of the instance. Valid values:
|
vpc |
| UserData |
string |
No |
The instance user data. The data must be Base64-encoded. The maximum size of the raw data is 32 KB. |
ZWNobyBoZWxsbyBlY3Mh |
| KeyPairName |
string |
No |
The name of the key pair.
|
testKeyPairName |
| RamRoleName |
string |
No |
The name of the instance RAM role. You can call the RAM API ListRoles 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.
|
2018-01-01T12:05:00Z |
| SpotStrategy |
string |
No |
The preemption policy for the pay-as-you-go instance. This parameter takes effect when
|
NoSpot |
| SpotPriceLimit |
number |
No |
The maximum hourly price of the instance. This parameter supports up to three decimal places and takes effect when |
0.97 |
| SpotDuration |
integer |
No |
The protection period of the spot instance. Unit: hours. Default value: 1. Valid values:
Alibaba Cloud sends an ECS system event notification 5 minutes before the instance is released. Spot instances are billed by second. Select an appropriate protection period based on the expected task execution duration. Note
This parameter takes effect only when SpotStrategy is set to SpotWithPriceLimit or SpotAsPriceGo. |
1 |
| ResourceGroupId |
string |
No |
The ID of the resource group to which the instance, block storage, and elastic network interface controller (NIC) belong. |
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:
|
Deactive |
| PrivateIpAddress |
string |
No |
The private IP address of the instance. When you specify a private IP address for a VPC-connected ECS instance, the IP address must be from the idle CIDR block of the vSwitch ( |
10.1.**.** |
| DeploymentSetId |
string |
No |
The ID of the deployment set. |
ds-bp1brhwhoqinyjd6**** |
| Ipv6AddressCount |
integer |
No |
The number of randomly generated IPv6 addresses to assign to the primary ENI. Valid values: 1 to 10. |
1 |
| DataDisk |
array<object> |
No |
The list of data disk information. |
|
|
object |
No |
The list of data disk information. |
||
| PerformanceLevel |
string |
No |
The performance level of the ESSD used as a data disk. The value of N must be the same as that in
For information about how to select an ESSD performance level, see Enterprise SSDs. |
PL1 |
| Description |
string |
No |
The description of the data disk. The description must be 2 to 256 characters in length and cannot start with |
testDataDiskDescription |
| SnapshotId |
string |
No |
The ID of the snapshot used to create data disk N. Valid values of N: 1 to 16. After you specify Note
You cannot use snapshots created on or before July 15, 2013. Such requests are rejected. |
s-bp17441ohwka0yuh**** |
| Size |
integer |
No |
The size of data disk N. Valid values of N: 1 to 16. Unit: GiB. Valid values:
The value of this parameter must be greater than or equal to the size of the snapshot specified by |
2000 |
| Device |
string |
No |
The mount point of the data disk. The naming convention varies based on the number of data disks attached:
Note
This parameter is intended only for full image (whole-machine image) scenarios. You can set this parameter to the mount point of a data disk in the full image and modify the corresponding |
/dev/xvdb |
| DiskName |
string |
No |
The name of the data disk. The name must be 2 to 128 characters in length. It must start with a letter and cannot start with |
testDataDiskName |
| Category |
string |
No |
The category of data disk N. Valid values:
For I/O optimized instances, the default value is cloud_efficiency. For non-I/O optimized instances, the default value is cloud. Default value description:
|
cloud_ssd |
| DeleteWithInstance |
boolean |
No |
Specifies whether to release the data disk when the instance is released. Valid values:
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{1,800 + 50 × Capacity, 50,000} Note
This parameter is supported only when DiskCategory is set to cloud_auto. For more information, see ESSD AutoPL disks and Modify the provisioned performance of an ESSD AutoPL disk. |
50000 |
| BurstingEnabled |
boolean |
No |
Specifies whether to enable the performance burst feature. Valid values:
|
true |
| KMSKeyId |
string |
No |
The KMS key ID for the data disk. |
0e478b7a-4262-4802-b8cb-00d**** |
| NetworkInterface |
array<object> |
No |
The network interface controller (NIC) information. |
|
|
object |
No |
The network interface controller (NIC) information. |
||
| VSwitchId |
string |
No |
The vSwitch ID of the network interface controller (NIC). Take note of the following items:
|
vsw-bp1s5fnvk4gn2tws0**** |
| NetworkInterfaceName |
string |
No |
The name of the network interface controller (NIC). Take note of the following items:
|
testEniName |
| Description |
string |
No |
The description of the secondary network interface controller (NIC). The description must be 2 to 256 characters in length and cannot start with |
testEniDescription |
| SecurityGroupId |
string |
No |
The ID of the security group to which the network interface controller (NIC) belongs. Take note of the following items:
|
sg-bp15ed6xe1yxeycg**** |
| PrimaryIpAddress |
string |
No |
Adds a network interface controller (NIC) and sets the primary IP address. Take note of the following items:
Note
When you create an ECS instance, you can attach up to one secondary NIC. After the instance is created, you can invoke CreateNetworkInterface and AttachNetworkInterface to attach more secondary NICs. |
192.168.**.** |
| SecurityGroupIds |
array |
No |
The IDs of one or more security groups to which the network interface controller (NIC) belongs.
Take note of the following items:
|
sg-bp67acfmxazb4p**** |
|
string |
No |
The IDs of one or more security groups to which the network interface controller (NIC) belongs.
Take note of the following items:
|
sg-bp67acfmxazb4p**** |
|
| InstanceType |
string |
No |
The type of the network interface controller (NIC). Valid values of N: 1 to 2. If you set N to 1, you can configure a primary or secondary NIC. If you set N to 2, you must configure one primary NIC and one secondary NIC. Valid values:
Default value: Secondary. |
Secondary |
| NetworkInterfaceTrafficMode |
string |
No |
The communication mode of the primary ENI. Valid values:
|
Standard |
| DeleteOnRelease |
boolean |
No |
Specifies whether to retain the ENI when the instance is released. Valid values:
Default value: true. Note
This parameter takes effect only for secondary ENIs. |
true |
| Tag |
array<object> |
No |
The tags for instances, disks, and primary ENIs created from this template version. |
|
|
object |
No |
The tags for instances, disks, and primary ENIs created from this template version. |
||
| Key |
string |
No |
The tag key for instances, disks, and primary ENIs created from this template version. 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 start with aliyun or acs:. The tag key cannot contain http:// or https://. |
TestKey |
| Value |
string |
No |
The tag value for instances, disks, and primary ENIs created from this template version. 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 one or more security groups to which the instance belongs. The valid value range of N depends on the maximum number of security groups to which an instance can belong. For more information, see Limits. Note
You cannot specify both |
sg-bp15ed6xe1yxeycg7**** |
|
string |
No |
The IDs of one or more security groups to which the instance belongs. The valid value range of N depends on the maximum number of security groups to which an instance can belong. For more information, see Limits. Note
You cannot specify both |
sg-bp15ed6xe1yxeycg7**** |
|
| SystemDisk.Encrypted |
string |
No |
Specifies whether to encrypt the system disk. Valid values:
Default value: false. Note
Zone D in Hong Kong (China) and Zone A in Singapore do not support system disk encryption when you create instances. |
false |
| DeletionProtection |
boolean |
No |
The release protection attribute of the instance. Specifies whether the instance can be released from the console or by calling DeleteInstance. Valid values:
Default value: false. Note
This attribute applies only to pay-as-you-go instances. It can only restrict manual release operations and does not affect system-initiated releases. |
false |
| CreditSpecification |
string |
No |
The running mode of the burstable instance. Valid values:
|
Standard |
| AutoRenew |
boolean |
No |
Specifies whether to enable auto-renewal. Valid values:
Default value: false. Note
This parameter takes effect only when |
true |
| AutoRenewPeriod |
integer |
No |
The auto-renewal period. Valid values: If 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 billable methods duration. Valid values: Month (default). |
Month |
| HttpEndpoint |
string |
No |
Specifies whether to enable the access channel for instance metadata. Valid values:
Default value: enabled. Note
For more information about instance metadata, see Overview of ECS instance metadata. |
enabled |
| HttpTokens |
string |
No |
Specifies whether to forcefully use the security-hardened mode (IMDSv2) to access instance metadata. Valid values:
Default value: optional. Note
For more information about the modes for Instance metadata overview |
optional |
| HttpPutResponseHopLimit |
integer |
No |
Note
This parameter is not available for use. |
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 |
Indicates whether the instance that uses this image supports logon with the ecs-user account. Valid values:
|
false |
| SecurityOptions |
object |
No |
The security options. |
|
| TrustedSystemMode |
string |
No |
The trusted system mode. Set the value to vTPM. The following instance families support trusted system mode:
When you create ECS instances of the preceding instance types, you must configure this parameter. Take note of the following items:
Note
If you specify the instance as a trusted instance during creation, you can replace the system disk only with an image that supports the trusted system. For more information about the trusted system, see Overview of trusted features for security-enhanced instances. |
vTPM |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| LaunchTemplateId |
string |
The launch template ID. |
lt-m5eiaupmvm2op9d**** |
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| LaunchTemplateVersionNumber |
integer |
The launch template version number. |
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.