tencent cloud

Feedback

CreateLaunchConfiguration

Last updated: 2024-10-25 15:16:30

    1. API Description

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

    This API is used to create a launch configuration.

    • To modify a launch configuration, please use ModifyLaunchConfigurationAttributes.

    • Up to 20 launch configurations can be created for each project. For more information, see Usage Limits.

    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: CreateLaunchConfiguration.
    Version Yes String Common Params. The value used for this API: 2018-04-19.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product.
    LaunchConfigurationName Yes String Display name of the launch configuration, which can contain letters, digits, underscores and hyphens (-), and dots. Up to of 60 bytes allowed..
    ImageId No String Image ID in the format of img-xxx. There are three types of images:
  • Public images
  • Custom images
  • Shared images

  • You can obtain the image IDs in the CVM console.
  • You can also use the DescribeImages and look for ImageId in the response.
  • ProjectId No Integer Project ID of the launch configuration. The default project is used if it’s left blank.
    Note that this project ID is not the same as the project ID of the scaling group.
    InstanceType No String Instance model. Different instance models specify different resource specifications. The specific value can be obtained by calling the DescribeInstanceTypeConfigs API to get the latest specification table or referring to the descriptions in Instance Types.
    InstanceType and InstanceTypes are mutually exclusive, and one and only one of them must be entered.
    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 Information of the instance's data disk configuration. If this parameter is not specified, no data disk is purchased by default. Up to 11 data disks can be supported.
    InternetAccessible No InternetAccessible Configuration of public network bandwidth. If this parameter is not specified, 0 Mbps will be used by default.
    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 The security group to which the instance belongs. This parameter can be obtained by calling the SecurityGroupId field in the returned value of DescribeSecurityGroups. If this parameter is not specified, no security group will be bound by default.
    EnhancedService No EnhancedService Enhanced services. You can use this parameter to specify whether to enable services such as Cloud Security and Cloud Monitor. If this parameter is not specified, Cloud Monitor and Cloud Security will be enabled by default.
    UserData No String Base64-encoded custom data of up to 16 KB.
    InstanceChargeType No String Instance billing mode. CVM instances take POSTPAID_BY_HOUR by default. Valid values:

  • POSTPAID_BY_HOUR: pay-as-you-go hourly

  • SPOTPAID: spot instance
  • InstanceMarketOptions No InstanceMarketOptionsRequest Market options of the instance, such as parameters related to spot instances. This parameter is required for spot instances.
    InstanceTypes.N No Array of String List of instance models. Different instance models specify different resource specifications. Up to 10 instance models can be supported.
    InstanceType and InstanceTypes are mutually exclusive, and one and only one of them must be entered.
    CamRoleName No String CAM role name. This parameter can be obtained from the roleName field returned by DescribeRoleList API.
    InstanceTypesCheckPolicy No String InstanceType verification policy, whose valid values include ALL and ANY, with the default value being ANY.
  • ALL: Verification passes if all InstanceTypes are available; otherwise, a verification error will be reported.
  • ANY: Verification passes if any InstanceType is available; otherwise, a verification error will be reported.


  • Common reasons for unavailable InstanceTypes include the InstanceType being sold out, and the corresponding cloud disk being sold out.
    If a model in InstanceTypes does not exist or has been abolished, a verification error will be reported regardless of the valid values set for InstanceTypesCheckPolicy.
    InstanceTags.N No Array of InstanceTag List of tags. This parameter is used to bind up to 10 tags to newly added instances.
    Tags.N No Array of Tag List of tags. You can specify tags that you want to bind to the launch configuration. Each launch configuration can have up to 30 tags.
    HostNameSettings No HostNameSettings CVM hostname settings.
    InstanceNameSettings No InstanceNameSettings Settings of CVM instance names
    If this field is configured in a launch configuration, the InstanceName of a CVM created by the scaling group will be generated according to the configuration; otherwise, it will be in the as-{{AutoScalingGroupName }} format.
    InstanceChargePrepaid No InstanceChargePrepaid Details of the monthly subscription, including the purchase period, auto-renewal. It is required if the InstanceChargeType is PREPAID.
    DiskTypePolicy No String Cloud disk type selection policy, whose default value is ORIGINAL. Valid values:
  • ORIGINAL: Use the set cloud disk type.
  • AUTOMATIC: Automatically select the currently available cloud disk type.
  • HpcClusterId No String HPC ID

    Note: This field is default to empty
    IPv6InternetAccessible No IPv6InternetAccessible IPv6 public network bandwidth configuration. If the IPv6 address is available in the new instance, public network bandwidth can be allocated to the IPv6 address. This parameter is invalid if Ipv6AddressCount of the scaling group associated with the launch configuration is 0.
    DisasterRecoverGroupIds.N No Array of String Placement group ID. Only one is allowed.
    ImageFamily No String Image family name. Either image ID or image family name should be filled in, and only one of which can be filled.

    3. Output Parameters

    Parameter Name Type Description
    LaunchConfigurationId String This parameter is returned when a launch configuration is created through this API, indicating the launch configuration ID.
    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 a launch configuration with required parameters

    This example shows you how to create a launch configuration by only assigning values for the required parameters (launch configuration name, instance model, and image ID) and using system default values for other parameters. The specific configuration is as follows: launch configuration name: as_test; instance model: Standard II 1C1G (S2.SMALL1); image ID: img-8toqc6s3.

    Input Example

    POST / HTTP/1.1
    Host: as.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateLaunchConfiguration
    <Common request parameters>
    
    {
        "ImageId": "img-8toqc6s3",
        "InstanceType": "S2.SMALL1",
        "LaunchConfigurationName": "as_test"
    }
    

    Output Example

    {
        "Response": {
            "LaunchConfigurationId": "asc-23h37kyn",
            "RequestId": "d639dd64-9e46-4246-b13c-80954f81c11b"
        }
    }
    

    Example2 Creating a launch configuration with detailed parameters

    This example shows you how to create a launch configuration by specifying the basic information (name, instance model, and image ID), and the system disk, data disk, public network billing mode and public network bandwidth cap. Get an auto-assigned public IP. Do not retain the data disk when an instance is terminated. Do not encrypt the data disk. Set the public network billing mode to pay-as-you-go by traffic on an hourly basis. Enable key login, Cloud Monitor and Anti-DDoS.

    Input Example

    POST / HTTP/1.1
    Host: as.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateLaunchConfiguration
    <Common request parameters>
    
    {
        "SystemDisk": {
            "DiskSize": "50",
            "DiskType": "LOCAL_BASIC"
        },
        "LoginSettings": {
            "KeyIds": [
                "skey-k8eypc1l"
            ]
        },
        "ImageId": "img-8toqc6s3",
        "EnhancedService": {
            "SecurityService": {
                "Enabled": "TRUE"
            },
            "MonitorService": {
                "Enabled": "TRUE"
            }
        },
        "LaunchConfigurationName": "as_test",
        "InternetAccessible": {
            "PublicIpAssigned": "TRUE",
            "InternetChargeType": "TRAFFIC_POSTPAID_BY_HOUR",
            "InternetMaxBandwidthOut": "5"
        },
        "InstanceType": "S2.SMALL1",
        "DataDisks": [
            {
                "Encrypt": "FALSE",
                "DeleteWithInstance": "TRUE",
                "DiskSize": "100",
                "DiskType": "CLOUD_BASIC"
            }
        ]
    }
    

    Output Example

    {
        "Response": {
            "LaunchConfigurationId": "asc-fdz8j7dh",
            "RequestId": "9a7209d3-2260-49d7-952a-dfa2001f8822"
        }
    }
    

    Example3 Creating a spot instance configuration

    This example shows you how to create a launch configuration with the following configurations. Launch configuration name: spot-test; model: Standard II 2C4G (S2.MEDIUM4); billing mode: spot instance (SPOTPAID); maximum bid: 0.99 USD/hr.

    Input Example

    POST / HTTP/1.1
    Host: as.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateLaunchConfiguration
    <Common request parameters>
    
    {
        "SystemDisk": {
            "DiskSize": "50",
            "DiskType": "CLOUD_PREMIUM"
        },
        "InstanceMarketOptions": {
            "SpotOptions": {
                "SpotInstanceType": "one-time",
                "MaxPrice": "0.99"
            },
            "MarketType": "spot"
        },
        "ImageId": "img-8toqc6s3",
        "InstanceChargeType": "SPOTPAID",
        "LaunchConfigurationName": "spot-test",
        "InternetAccessible": {
            "PublicIpAssigned": "true",
            "InternetChargeType": "TRAFFIC_POSTPAID_BY_HOUR",
            "InternetMaxBandwidthOut": "20"
        },
        "InstanceType": "S2.MEDIUM4"
    }
    

    Output Example

    {
        "Response": {
            "LaunchConfigurationId": "asc-hpzwe3o2",
            "RequestId": "ccfe3052-e9c9-47ee-bf3d-5bc2dfd972c0"
        }
    }
    

    Example4 Creating a launch configuration that supports multiple instance models

    This example shows you how to create a launch instance that supports two instance models: S2.SMALL2 and S2.SMALL4.

    Input Example

    POST / HTTP/1.1
    Host: as.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateLaunchConfiguration
    <Common request parameters>
    
    {
        "ImageId": "img-8toqc6s3",
        "InstanceTypes": [
            "S2.SMALL4",
            "S2.SMALL2"
        ],
        "LaunchConfigurationName": "multi_instance_types"
    }
    

    Output Example

    {
        "Response": {
            "LaunchConfigurationId": "asc-77mh1cho",
            "RequestId": "2864c860-27a0-439e-a1e1-0003b76734e7"
        }
    }
    

    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
    InternalError.CallStsError The STS API call failed.
    InternalError.CalleeError Exceptions occurred while invoking other services.
    InvalidParameter.ActionNotFound Invalid Action request.
    InvalidParameter.Conflict Multiple parameters specified conflict and cannot co-exist.
    InvalidParameter.HostNameUnavailable The hostname parameter is unavailable to this image.
    InvalidParameter.InvalidCombination Invalid parameter combination.
    InvalidParameter.MustOneParameter A parameter is missing. One of the two parameters must be specified.
    InvalidParameter.ParameterDeprecated This parameter has been disused.
    InvalidParameter.ParameterMustBeDeleted Some parameters cannot coexist and should be deleted.
    InvalidParameterValue.AccountNotSupportBandwidthPackageId The bandwidth package ID is not supported in this account.
    InvalidParameterValue.CvmConfigurationError Exception with CVM parameter validation.
    InvalidParameterValue.HostNameIllegal Invalid hostname
    InvalidParameterValue.HostNameWithSuffixTooLong HostNames with suffixes are too long and exceed the specified upper limit.
    InvalidParameterValue.IPv6InternetChargeType The specified IPv6 public network bandwidth billing mode is invalid.
    InvalidParameterValue.ImageNotFound The specified image does not exist.
    InvalidParameterValue.InstanceNameIllegal Invalid instance name
    InvalidParameterValue.InstanceNameWithSuffixTooLong Instance names with suffixes are too long and exceed the specified upper limit.
    InvalidParameterValue.InstanceTypeNotSupported The instance type is not supported.
    InvalidParameterValue.InvalidDisasterRecoverGroupId The format of the placement group ID is incorrect.
    InvalidParameterValue.InvalidHpcClusterId The HPC ID is invalid.
    InvalidParameterValue.InvalidImageId Invalid image ID.
    InvalidParameterValue.InvalidInstanceType Invalid instance type.
    InvalidParameterValue.InvalidLaunchConfiguration Invalid launch configuration
    InvalidParameterValue.InvalidSecurityGroupId Invalid security group ID.
    InvalidParameterValue.InvalidSnapshotId Invalid snapshot ID.
    InvalidParameterValue.LaunchConfigurationNameDuplicated The launch configuration name already exists.
    InvalidParameterValue.LimitExceeded The value exceeds the limit.
    InvalidParameterValue.MissingBandwidthPackageId The bandwidth package ID is required.
    InvalidParameterValue.NotStringTypeFloat The value should be a floating point string.
    InvalidParameterValue.ProjectIdNotFound The project ID does not exist.
    InvalidParameterValue.TooLong Too many values.
    InvalidParameterValue.TooShort The value of input parameter is too short.
    InvalidParameterValue.UserDataFormatError Incorrect UserData format.
    InvalidParameterValue.UserDataSizeExceeded The UserData is too long.
    InvalidPermission The account does not support this operation.
    LimitExceeded.LaunchConfigurationQuotaNotEnough You are short of the launch configuration quota.
    MissingParameter Parameter missing.
    MissingParameter.InstanceMarketOptions The InstanceMarketOptions parameter of the spot instance is missing.
    ResourceNotFound.BandwidthPackageIdNotFound The specified bandwidth package ID is not found.
    ResourceNotFound.DisasterRecoverGroupNotFound The specified placement group ID does not exist.
    UnauthorizedOperation.AutoScalingRoleUnauthorized You have not assigned the CAM role AS-QCSRole to Auto Scaling. Please go to the AS console to complete authorization first.