tencent cloud

文档反馈

CreateLaunchTemplateVersion

最后更新时间:2024-10-22 19:33:58

    1. API Description

    Domain name for API request: cvm.tencentcloudapi.com.

    This API is used to create an instance launch template based on the specified template ID and the corresponding template version number. The default version number will be used when no template version numbers are specified. Each instance launch template can have up to 30 version numbers.

    A maximum of 20 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    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: CreateLaunchTemplateVersion.
    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.
    Placement Yes Placement Location of the instance. You can use this parameter to specify the attributes of the instance, such as its availability zone, project, and CDH (for dedicated CVMs)
    LaunchTemplateId Yes String Instance launch template ID. This parameter is used as a basis for creating new template versions.
    LaunchTemplateVersion No Integer This parameter, when specified, is used to create instance launch templates. If this parameter is not specified, the default version will be used.
    LaunchTemplateVersionDescription No String Description of instance launch template versions. This parameter can contain 2-256 characters.
    InstanceType No String Instance model. Different instance models specify different resource specifications.


  • For instances created with the payment modes PREPAID or POSTPAID_BY_HOUR, the specific values can be obtained by calling the DescribeInstanceTypeConfigs API for the latest specification table or referring to Instance Specifications. If this parameter is not specified, the system will dynamically assign a default model based on the current resource sales situation in a region.

  • For instances created with the payment mode CDHPAID, this parameter has the prefix "CDH_" and is generated based on the CPU and memory configuration. The specific format is: CDH_XCXG. For example, for creating a CDH instance with 1 CPU core and 1 GB memory, this parameter should be CDH_1C1G.
  • ImageId No String The image ID in the format of img-xxx. There are four types of images:
  • Public images
  • Custom images
  • Shared images
  • Marketplace images (for Chinese mainland only)

  • To check the image ID:
  • For public images, custom images, and shared images, go to the console. For marketplace images, go to Cloud Marketplace.
  • Call DescribeImages, pass in InstanceType to retrieve the list of images supported by the current model, and then find the ImageId in the response.
  • SystemDisk No SystemDisk System disk configuration of the instance. If this parameter is not specified, the default value will be used.
    DataDisks.N No Array of DataDisk The configuration information of instance data disks. If this parameter is not specified, no data disk will be purchased by default. When purchasing, you can specify 21 data disks, which can contain at most 1 LOCAL_BASIC or LOCAL_SSD data disk, and at most 20 CLOUD_BASIC, CLOUD_PREMIUM, or CLOUD_SSD data disks.
    VirtualPrivateCloud No VirtualPrivateCloud Configuration information of VPC. This parameter is used to specify VPC ID and subnet ID, etc. If this parameter is not specified, the classic network is used by default. If a VPC IP is specified in this parameter, it indicates the primary ENI IP of each instance. The value of parameter InstanceCount must be same as the number of VPC IPs, which cannot be greater than 20.
    InternetAccessible No InternetAccessible Configuration of public network bandwidth. If this parameter is not specified, 0 Mbps will be used by default.
    InstanceCount No Integer Number of instances to be purchased. Value range for monthly-subscribed instances: [1, 300]. Value range for pay-as-you-go instances: [1, 100]. Default value: 1. The specified number of instances to be purchased cannot exceed the remaining quota allowed for the user. For more information on quota, see CVM instance Purchase Limits.
    InstanceName No String Instance name.
  • If this parameter is not specified, "Unnamed" will be displayed by default.
  • If you purchase multiple instances and specify a pattern string {R:x}, numbers [x, x+n-1] will be generated, where n represents the number of instances purchased. For example, you specify a pattern string server_{R:3}. If you purchase only one instance, the instance will be named server_3; if you purchase two, they will be named server_3 and server_4. You can specify multiple pattern strings in the format of {R:x}.
  • If you purchase multiple instances without specifying a pattern string, the instance names will be suffixed with 1, 2...n, where n represents the number of instances purchased. For example, if you purchase two instances with the name server_, the instance names will be server_1 and server_2.
  • This parameter can contain up to 60 characters (including pattern strings).
  • LoginSettings No LoginSettings Login settings of the instance. You can use this parameter to set the login method, password, and key of the instance or keep the login settings of the original image. By default, a random password will be generated and sent to you via the Message Center.
    SecurityGroupIds.N No Array of String Security groups to which the instance belongs. To obtain the security group IDs, you can call DescribeSecurityGroups and look for the sgld fields in the response. If this parameter is not specified, the instance will be associated with default security groups.
    EnhancedService No EnhancedService Enhanced service. You can use this parameter to specify whether to enable services such as Anti-DDoS and Cloud Monitor. If this parameter is not specified, Cloud Monitor and Anti-DDoS are enabled for public images by default. However, for custom images and images from the marketplace, Anti-DDoS and Cloud Monitor are not enabled by default. The original services in the image will be retained.
    ClientToken No String A unique string supplied by the client to ensure that the request is idempotent. Its maximum length is 64 ASCII characters. If this parameter is not specified, the idempotency of the request cannot be guaranteed.
    HostName No String Hostname of Cloud Virtual Machine.
  • Period (.) and hyphen (-) should not be used as the first or last character of the hostname, and should not be used consecutively.

  • Windows instances: The hostname should contain 2 to 15 characters, including letters (case insensitive), digits, and hyphens (-), does not support periods (.), and should not be all digits.

  • Instances of other types (such as Linux instances): The hostname should contain 2 to 60 characters, including multiple periods (.), with each segment between periods considered as one section. Each section can contain letters (case insensitive), digits, and hyphens (-).
  • ActionTimer No ActionTimer Scheduled tasks. You can use this parameter to specify scheduled tasks for the instance. Only scheduled termination is supported.
    DisasterRecoverGroupIds.N No Array of String Placement group ID. You can only specify one.
    TagSpecification.N No Array of TagSpecification The tag description list. This parameter is used to bind a tag to a resource instance. A tag can only be bound to CVM instances.
    InstanceMarketOptions No InstanceMarketOptionsRequest Market options of the instance, such as parameters related to spot instances. This parameter is required for spot instances.
    UserData No String User data provided to the instance. This parameter needs to be encoded in base64 format with the maximum size of 16KB. For more information on how to get the value of this parameter, see the commands you need to execute on startup for Windows or Linux.
    DryRun No Boolean Whether the request is a dry run only.
    true: dry run only. The request will not create instance(s). A dry run can check whether all the required parameters are specified, whether the request format is right, whether the request exceeds service limits, and whether the specified CVMs are available.
    If the dry run fails, the corresponding error code will be returned.
    If the dry run succeeds, the RequestId will be returned.
    false (default value): send a normal request and create instance(s) if all the requirements are met.
    CamRoleName No String CAM role name, which can be obtained from the roleName field in the response of the DescribeRoleList API.
    HpcClusterId No String HPC cluster ID. The HPC cluster must and can only be specified for a high-performance computing instance.
    InstanceChargeType No String Instance billing mode.
  • PREPAID: prepaid, that is, monthly subscription.
  • POSTPAID_BY_HOUR: pay-as-you-go by hour.
  • CDHPAID: CDH instance (created based on CDH; the resources of the host are free of charge).
  • SPOTPAID: spot payment.
  • Default value: POSTPAID_BY_HOUR.
    InstanceChargePrepaid No InstanceChargePrepaid Details of the monthly subscription, including the purchase period, auto-renewal. It is required if the InstanceChargeType is PREPAID.
    DisableApiTermination No Boolean Instance termination protection flag, indicating whether an instance is allowed to be deleted through an API. Valid values:
  • TRUE: Instance protection is enabled, and the instance is not allowed to be deleted through the API.

  • FALSE: Instance protection is disabled, and the instance is allowed to be deleted through the API.


  • Default value: FALSE.

    3. Output Parameters

    Parameter Name Type Description
    LaunchTemplateVersionNumber Integer Version number of the new instance launch template.
    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.

    4. Example

    Example1 Creating an instance launch template version

    This example shows you how to create a new launch template version in Guangzhou Zone 1.

    Input Example

    GET https://cvm.tencentcloudapi.com/?Action=CreateLaunchTemplateVersion
    &Placement.Zone=ap-guangzhou-1
    &LaunchTemplateId=lt-lobxe2yo
    &<Common request parameters>
    

    Output Example

    {
        "Response": {
            "LaunchTemplateVersionNumber": 7,
            "RequestId": "9b4ad85f-1657-4445-111d-3c0a9fbec309"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    AuthFailure.CamRoleNameAuthenticateFailed Role name authentication failed.
    FailedOperation.DisasterRecoverGroupNotFound The specified spread placement group does not exist.
    FailedOperation.InquiryPriceFailed Price query failed.
    FailedOperation.TagKeyReserved The tag key specified in the request is reserved for the system.
    InternalError.TradeUnknownError Internal error.
    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 60 bytes.
    InvalidInstanceType.Malformed The specified InstanceType parameter has an invalid format.
    InvalidParameter.InstanceImageNotSupport This API does not support instance images.
    InvalidParameter.InvalidIpFormat Invalid VPC IP address format.
    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.IllegalHostName The value of HostName is invalid.
    InvalidParameterValue.InstanceTypeNotSupportHpcCluster This type of instances cannot be added to the HPC cluster.
    InvalidParameterValue.InvalidImageState The image has another ongoing task. Please check and try again later.
    InvalidParameterValue.InvalidIpFormat Invalid IP address.
    InvalidParameterValue.InvalidLaunchTemplateVersionDescription Incorrect format of instance launch template version description.
    InvalidParameterValue.InvalidUserDataFormat Incorrect UserData format. Use the Base64-encoded format.
    InvalidParameterValue.LaunchTemplateIdMalformed Incorrect format of instance launch template ID. Please provide a valid instance launch template ID, similar to lt-xxxxxxxx, where x represents a lowercase character or digit.
    InvalidParameterValue.LaunchTemplateIdNotExisted The instance launch template ID does not exist.
    InvalidParameterValue.LaunchTemplateIdVerNotExisted The combination of the template and the version ID does not exist.
    InvalidParameterValue.LaunchTemplateNotFound The instance launch template is not found.
    InvalidParameterValue.LaunchTemplateVersion Invalid instance launch template version number.
    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.VpcIdZoneIdNotMatch The VPC and instance must be in the same availability zone.
    InvalidParameterValue.VpcNotSupportIpv6Address This VPC does not support the IPv6 addresses.
    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.LaunchTemplateVersionQuota The number of instance launch template versions 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.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
    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.
    UnknownParameter Unknown parameter error.
    UnsupportedOperation Unsupported operation.
    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.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.