Domain name for API request: cvm.intl.tencentcloudapi.com.
This interface (CreateLaunchTemplate) is used for instance launch template creation.
An instance launch template is a configuration data and can be used to create instances. Its content includes configurations required to create instances, such as instance type, types and sizes of data disk and system disk, and security group and other information.
This API is used to create an instance launch template. After the initial creation of the instance template, its template version is the default version 1. A new version can be created using CreateLaunchTemplateVersion (https://www.tencentcloud.com/document/product/213/66326?from_cn_redirect=1), and the version number will increment. By default, when specifying an instance launch template in RunInstances (https://www.tencentcloud.com/document/product/213/15730?from_cn_redirect=1), if the template version number is not specified, the default version will be used.
A maximum of 20 requests can be initiated per second for this API.
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | Common Params. The value used for this API: CreateLaunchTemplate. |
| Version | Yes | String | Common Params. The value used for this API: 2017-03-12. |
| Region | Yes | String | Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-bangkok, ap-beijing, ap-chengdu, ap-chongqing, ap-guangzhou, ap-hongkong, ap-jakarta, ap-nanjing, ap-seoul, ap-shanghai, ap-shanghai-fsi, ap-shenzhen-fsi, ap-singapore, ap-tokyo, eu-frankfurt, na-ashburn, na-siliconvalley, sa-saopaulo. |
| LaunchTemplateName | Yes | String | Name of an instance launch template. It contains 2 to 128 English or Chinese characters. |
| Placement | Yes | Placement | Location of the instance. You can specify attributes such as availability zone, project, and host (specified when creating a instance on the CDH) to which the instance belongs through this parameter. |
| ImageId | Yes | String | Specify an effective mirror ID in the format of img-xxx. there are four image types: PUBLIC image, custom image and shared image can be queried by logging in to the console; the mirror ids of service market image can be queried through the cloud market.ImageId field from the return information. |
| LaunchTemplateVersionDescription | No | String | Version description of an instance launch template. It contains 2 to 256 English or Chinese characters. |
| InstanceType | No | String | Instance model. Different instance models specify different resource specifications. |
| SystemDisk | No | SystemDisk | Instance system disk configuration information. If this parameter is not specified, it will be assigned based on the system default values. |
| DataDisks.N | No | Array of DataDisk | Instance data disk configuration information. if not specified, no data disks are purchased by default. support specifying 21 data disks at the time of purchase, among which a maximum of 1 LOCAL_BASIC data disk or LOCAL_SSD data disk can be included, and a maximum of 20 CLOUD_BASIC data disks, CLOUD_PREMIUM data disks or CLOUD_SSD data disks can be included. |
| VirtualPrivateCloud | No | VirtualPrivateCloud | VPC-related information configuration. You can specify information such as VPC ID and subnet ID through this parameter. If this parameter is not specified, use the basic network by default. If a VPC IP is specified in this parameter, it indicates the primary network interface card IP of each instance. In addition, the number of the InstanceCount parameter should be consistent with the number of the VPC IP and should not exceed 20. |
| InternetAccessible | No | InternetAccessible | Public bandwidth-related settings. If this parameter is not specified, the public bandwidth is 0 Mbps by default. |
| InstanceCount | No | Integer | Number of instances to purchase. value range for monthly subscription instances: [1, 300]. value range for pay-as-you-go instances: [1, 100]. default value: 1. the number of instances to purchase must not exceed the remaining user quota. for specific quota limitations, see CVM instance purchase limitations. |
| InstanceName | No | String | Instance display name. {R:x} is specified, it indicates generating numbers [x, x+n-1], where n represents the number of purchased instances. for example, server_{R:3} will result in instance display names as server_3 when purchasing 1 instance; when purchasing 2 instances, the instance display names will be server_3 and server_4 respectively. it supports specifying multiple pattern strings {R:x}.1, 2...n will be added to the instance display name, where n represents the number of purchased instances. for example, for server_, when purchasing 2 instances, the instance display names will be server_1 and server_2 respectively. |
| LoginSettings | No | LoginSettings | Instance login settings. this parameter allows you to set the instance login method to key or maintain the original login settings of the image. |
| SecurityGroupIds.N | No | Array of String | Security group to which an instance belongs. this parameter can be obtained by calling the sgId field in the returned value of DescribeSecurityGroups. if not specified, the default security group is bound. |
| EnhancedService | No | EnhancedService | Enhanced services. You can specify whether to enable services such as Cloud Security and Cloud Monitor through this parameter. If this parameter is not specified, Cloud Monitor and Cloud Security are enabled for public images by default, but not enabled for custom images and marketplace images by default. Instead, they use services retained in the images. |
| ClientToken | No | String | A string used to ensure the idempotence of the request. This string is generated by the customer and should be unique across different requests, with a maximum length of 64 ASCII characters. If this parameter is not specified, the idempotence of the request cannot be guaranteed. |
| HostName | No | String | Specifies the HostName of the cloud virtual machine. |
| ActionTimer | No | ActionTimer | Scheduled task. You can specify a scheduled task for the instance through this parameter. Currently, only scheduled termination is supported. |
| DisasterRecoverGroupIds.N | No | Array of String | Placement group ID. Only one can be specified. |
| TagSpecification.N | No | Array of TagSpecification | List of tag descriptions. You can bind tags to corresponding resource instances at the same time by specifying this parameter. Currently, only binding tags to the CVM is supported. |
| InstanceMarketOptions | No | InstanceMarketOptionsRequest | Market-Related options of the instance, such as relevant parameters of the bidding instance. this parameter is required if the payment mode of the specified instance is spot payment. |
| UserData | No | String | User data provided for an instance must be encoded in base64. valid values for maximum data size are up to 16 KB. for details on obtaining this parameter, see running commands at startup for Windows (https://www.tencentcloud.com/document/product/213/17526?from_cn_redirect=1) and Linux (https://www.tencentcloud.com/document/product/213/17525?from_cn_redirect=1). |
| DryRun | No | Boolean | Whether it is a pre-check for this request only. true: sends a check request without creating an instance. check items include whether required parameters are filled in, request format, service limits, and cvm inventory. If the check fails, return the corresponding error code. If the check passed, return RequestId. false (default): sends a normal request. after passing the check, creates an instance directly. |
| CamRoleName | No | String | CAM role name. it can be obtained through the roleName in the return value from the API DescribeRoleList. |
| HpcClusterId | No | String | High-performance computing cluster ID. If the created instance is a high-performance computing instance, the cluster where the instance is placed should be specified. Otherwise, it cannot be specified. |
| InstanceChargeType | No | String | Instance billing mode. |
| InstanceChargePrepaid | No | InstanceChargePrepaid | Prepaid mode, that is, annual and monthly subscription related parameter settings. Through this parameter, you can specify the purchase duration of annual and monthly subscription instances, whether to set auto-renewal, etc. If the specified instance's billing mode is the prepaid mode, this parameter must be passed. |
| DisableApiTermination | No | Boolean | Instance destruction protection flag: indicates whether an instance is allowed to be deleted through an api. value ranges from: - TRUE: indicates that instance protection is enabled, deletion through apis is not allowed. - FALSE: indicates that instance protection is disabled, deletion through apis is allowed. default value: FALSE. |
| EnableJumboFrame | No | Boolean | |
| LaunchTemplateTagSpecification.N | No | Array of TagSpecification | Description list of tags. by specifying this parameter, tags can be bound to the instance launch template. |
| Metadata | No | Metadata | Custom metadata. specifies that custom metadata key-value pairs can be added when creating a CVM. Note: this field is in beta test. |
| TemplateDataModifyAction | No | String | Specifies that only the Update and Replace parameters are allowed. this parameter is valid only when custom Metadata is used in the template and Metadata is also transmitted in RunInstances. defaults to Replace. -Update: if template t contains this parameter with a value of Update and metadata=[k1:v1, k2:v2], then RunInstances (with metadata=[k2:v3]) + t creates a cvm using metadata=[k1:v1, k2:v3]. -Replace: if the template t contains this parameter with a value of Replace and metadata=[k1:v1, k2:v2], then when creating a cvm using RunInstances (with metadata=[k2:v3]) + t, the created cvm will use metadata=[k2:v3]. Note: this field is in beta test. |
| Parameter Name | Type | Description |
|---|---|---|
| LaunchTemplateId | String | Specifies the ID of the successfully created instance launch template when this parameter is returned by creating an instance launch template through this interface. |
| RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
This example shows you how to only pass the required parameters such as Zone, image id and launch template ID, while other parameters use system default values. Specific configuration is as follows: The instance location is Guangzhou Zone 6, the image id is img-pmqg1cw7, and the instance launch template name is myTemplate.
POST / HTTP/1.1
Host: cvm.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLaunchTemplate
<Common request parameters>
{
"LaunchTemplateName": "myTemplate",
"Placement": {
"Zone": "ap-guangzhou-6"
},
"ImageId": "img-pmqg1cw7"
}{
"Response": {
"LaunchTemplateId": "lt-lobxe2yo",
"RequestId": "9b4ad85f-1657-4445-111d-3c0a9fbec309"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
| Error Code | Description |
|---|---|
| AccountQualificationRestrictions | Your account failed the qualification verification. |
| AuthFailure.CamRoleNameAuthenticateFailed | Role name authentication failed. |
| FailedOperation.DisasterRecoverGroupNotFound | The specified spread placement group does not exist. |
| FailedOperation.InquiryPriceFailed | Price query failed. |
| FailedOperation.NoAvailableIpAddressCountInSubnet | No available IPs in the subnet. |
| FailedOperation.SecurityGroupActionFailed | Security group operation failed. |
| FailedOperation.SnapshotSizeLargerThanDataSize | The snapshot size is larger than the disk capacity. You need a larger disk space. |
| FailedOperation.TagKeyReserved | The tag key specified in the request is reserved for the system. |
| InstancesQuotaLimitExceeded | You are trying to create more instances than your remaining quota allows. |
| InternalError.TradeUnknownError | Internal error. |
| InvalidAccount.InsufficientBalance | Insufficient account balance. |
| InvalidClientToken.TooLong | The specified ClientToken exceeds the maximum length of 64 bytes. |
| InvalidHostId.Malformed | Invalid CDH ID. The specified CDH ID has an invalid format. For example, host-1122 has an invalid ID length. |
| InvalidHostId.NotFound | The specified HostId does not exist, or does not belong to your account. |
| InvalidImageId.Malformed | Invalid image ID format. |
| InvalidImageId.NotFound | The image cannot be found. |
| InvalidInstanceName.TooLong | The specified InstanceName exceeds the maximum length of 128 bytes. |
| InvalidInstanceType.Malformed | The specified InstanceType parameter has an invalid format. |
| InvalidParameter.InstanceImageNotSupport | This API does not support instance images. |
| InvalidParameter.InternetAccessibleNotSupported | Unable to set the public network bandwidth. |
| InvalidParameter.InvalidIpFormat | Invalid VPC IP address format. |
| InvalidParameter.LackCoreCountOrThreadPerCore | CoreCount and ThreadPerCore must be specified at the same time. |
| InvalidParameter.PasswordNotSupported | Setting login password is not supported. |
| InvalidParameter.SnapshotNotFound | The specified snapshot does not exist. |
| InvalidParameterCombination | The parameter combination is invalid. |
| InvalidParameterValue | Incorrect parameter value. |
| InvalidParameterValue.CloudSsdDataDiskSizeTooSmall | The minimum capacity of a SSD data disk is 100 GB. |
| InvalidParameterValue.CoreCountValue | Invalid number of cores. |
| InvalidParameterValue.IllegalHostName | The value of HostName is invalid. |
| InvalidParameterValue.InstanceTypeNotSupportHpcCluster | This type of instances cannot be added to the HPC cluster. |
| InvalidParameterValue.InstanceTypeRequiredHpcCluster | The HPC cluster needs to be specified for the high-performance computing instance. |
| InvalidParameterValue.InsufficientOffering | The spot instances are out of stock. |
| InvalidParameterValue.InsufficientPrice | The bid is lower than the market price. |
| InvalidParameterValue.InvalidAppIdFormat | Invalid AppID |
| InvalidParameterValue.InvalidImageForGivenInstanceType | The specified image does not support the specified instance type. |
| InvalidParameterValue.InvalidImageId | The image does not support this operation. |
| InvalidParameterValue.InvalidImageState | The image has another ongoing task. Please check and try again later. |
| InvalidParameterValue.InvalidIpFormat | Invalid IP address. |
| InvalidParameterValue.InvalidLaunchTemplateDescription | Instance boot template description format is incorrect. |
| InvalidParameterValue.InvalidLaunchTemplateName | Incorrect format of instance launch template name. |
| InvalidParameterValue.InvalidLaunchTemplateVersionDescription | Incorrect format of instance launch template version description. |
| InvalidParameterValue.InvalidPassword | Invalid password. The specified password does not meet the complexity requirements (e.g., too long or too short) |
| InvalidParameterValue.InvalidTimeFormat | Incorrect time format. |
| InvalidParameterValue.InvalidUserDataFormat | Incorrect UserData format. Use the Base64-encoded format. |
| InvalidParameterValue.LimitExceeded | The number of parameter values exceeds the limit. |
| InvalidParameterValue.MustDhcpEnabledVpc | The parameter value must be a DHCP-enabled VPC. |
| InvalidParameterValue.Range | Invalid parameter value: invalid parameter value range. |
| InvalidParameterValue.SnapshotIdMalformed | Invalid snapshot ID. Provide a snapshot ID in the format of snap-xxxxxxxx, where the letter x refers to lowercase letter or number. |
| InvalidParameterValue.SubnetNotExist | Creation failed: the subnet does not exist. Please specify another subnet. |
| InvalidParameterValue.ThreadPerCoreValue | Invalid thread count per core. |
| InvalidParameterValue.VpcIdMalformed | The VPC ID xxx is invalid. Please provide a VPC ID in the format of vpc-xxxxxxxx, where “x” can be a lowercase letter or number. |
| InvalidParameterValue.VpcIdNotExist | The specified VpcId doesn't exist. |
| InvalidParameterValue.VpcIdZoneIdNotMatch | The VPC and instance must be in the same availability zone. |
| InvalidParameterValue.ZoneNotSupported | The availability zone does not support this operation. |
| InvalidPassword | Invalid password. The specified password does not meet the password requirements. For example, the password length does not meet the requirements. |
| InvalidPeriod | Invalid period. Valid values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36]; unit: month. |
| InvalidPermission | This operation is not supported for the account. |
| InvalidProjectId.NotFound | Invalid project ID: the specified project ID does not exist. |
| InvalidSecurityGroupId.NotFound | The specified security group ID does not exist. |
| InvalidZone.MismatchRegion | The specified zone does not exist. |
| LimitExceeded.InstanceQuota | You are short of the instance quota. |
| LimitExceeded.LaunchTemplateQuota | The number of instance launch templates exceeds the limit. |
| LimitExceeded.SingleUSGQuota | The number of security groups exceeds the quota limit. |
| LimitExceeded.SpotQuota | The spot instance offerings are out of stock. |
| LimitExceeded.UserSpotQuota | You are short of the spot instance quota. |
| LimitExceeded.VpcSubnetNum | Insufficient subnet IPs. |
| MissingParameter | Missing parameter. |
| MissingParameter.DPDKInstanceTypeRequiredVPC | The DPDK instance requires a VPC. |
| MissingParameter.MonitorService | The instance type must have Cloud Monitor enabled. |
| ResourceInsufficient.AvailabilityZoneSoldOut | The availability zone has been sold out. |
| ResourceInsufficient.CloudDiskSoldOut | The specified cloud disk has been sold out. |
| ResourceInsufficient.CloudDiskUnavailable | The parameters of cloud disk do not meet the specification. |
| ResourceInsufficient.DisasterRecoverGroupCvmQuota | The number of instances exceeded the quota limit of spread placement groups. |
| ResourceInsufficient.SpecifiedInstanceType | The specified instance type is insufficient. |
| ResourceNotFound.HpcCluster | The HPC cluster does not exist. |
| ResourceNotFound.KeyPairNotFound | The specified key pair does not exist. |
| ResourceNotFound.NoDefaultCbs | No default CBS resources are available. |
| ResourceNotFound.NoDefaultCbsWithReason | No default CBS resources are available. |
| ResourceUnavailable.InstanceType | This instance type is unavailable in the availability zone. |
| ResourcesSoldOut.EipInsufficient | The public IP has been sold out. |
| ResourcesSoldOut.SpecifiedInstanceType | The specified instance type is sold out. |
| UnsupportedOperation.BandwidthPackageIdNotSupported | The specified instance or network cannot use the bandwidth package. |
| UnsupportedOperation.InstanceTypeNotSupportJumboFrame | The instance type does not support setting the EnableJumboFrame status. |
| UnsupportedOperation.InvalidDisk | The specified disk is not supported. |
| UnsupportedOperation.KeyPairUnsupportedWindows | Key-pair login is not available to Windows instances. |
| UnsupportedOperation.NoInstanceTypeSupportSpot | This instance type does not support spot instances. |
| UnsupportedOperation.NotSupportImportInstancesActionTimer | Failed to configure the scheduled action for the current instance. |
| UnsupportedOperation.OnlyForPrepaidAccount | Only a prepaid account supports this operation. |
| VpcAddrNotInSubNet | The VPC IP address is not in the subnet. |
| VpcIpIsUsed | The VPC IP address is already occupied. |
文档反馈