CreateLoadBalancer

Last updated: 2021-09-15 16:11:18

    1. API Description

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

    This API (CreateLoadBalancer) is used to create a CLB instance. To use the CLB service, you first need to purchase one or more instances. After this API is called successfully, a unique instance ID will be returned. There are two types of instances: public network and private network. For more information, see the product types in the product documentation.
    Note: (1) To apply for a CLB instance in the specified AZ and cross-AZ disaster recovery, please submit a ticket; (2) Currently, IPv6 is supported only in Beijing, Shanghai, and Guangzhou regions.
    This is an async API. After it is returned successfully, you can call the DescribeLoadBalancers API to query the status of the instance (such as creating and normal) to check whether it is successfully created.

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

    Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: clb.ap-shanghai-fsi.tencentcloudapi.com

    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 parameter. The value used for this API: CreateLoadBalancer.
    Version Yes String Common parameter. The value used for this API: 2018-03-17.
    Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
    LoadBalancerType Yes String CLB instance network type:
    OPEN: public network; INTERNAL: private network.
    Forward No Integer CLB instance type. Valid value: 1 (generic CLB instance).
    LoadBalancerName No String CLB instance name, which takes effect only when only one instance is to be created in the request. It can consist 1 to 60 letters, digits, hyphens (-), or underscores (_).
    Note: if the name of the new CLB instance already exists, a default name will be generated automatically.
    VpcId No String Network ID of the target CLB real server, such as vpc-12345678, which can be obtained through the DescribeVpcEx API. If this parameter is not specified, it will default to DefaultVPC. This parameter is required for creating a CLB instance.
    SubnetId No String A subnet ID must be specified when you purchase a private network CLB instance in a VPC, and the VIP of this instance will be generated in this subnet. This parameter is required for creating a CLB instance.
    ProjectId No Integer Project ID of the CLB instance, which can be obtained through the DescribeProject API. If this parameter is not specified, it will default to the default project.
    AddressIPVersion No String IP version. Valid values: IPV4 (default), IPV6 (IPV6 NAT64 version) or IPv6FullChain (IPv6 version). This parameter is only for public network CLB instances.
    Number No Integer Number of CLBs to be created. Default value: 1.
    MasterZoneId No String Sets the primary AZ ID for cross-AZ disaster recovery, such as 100001 or ap-guangzhou-1, which is applicable only to public network CLB.
    Note: A primary AZ carries traffic, while a secondary AZ does not carry traffic by default and will be used only if the primary AZ becomes unavailable. The platform will automatically select the optimal secondary AZ. The list of primary AZs in a specific region can be queried through the DescribeMasterZones API.
    ZoneId No String Specifies an AZ ID for creating a CLB instance, such as ap-guangzhou-1, which is applicable only to public network CLB instances.
    InternetAccessible No InternetAccessible CLB network billing mode. This parameter is applicable only to public network CLB instances.
    VipIsp No String This parameter is applicable only to public network CLB instances. Valid values: CMCC (China Mobile), CTCC (China Telecom), CUCC (China Unicom). If this parameter is not specified, BGP will be used by default. ISPs supported in a region can be queried with the DescribeSingleIsp API. If an ISP is specified, only bill-by-bandwidth-package (BANDWIDTH_PACKAGE) can be used as the network billing mode.
    Tags.N No Array of TagInfo Tags a CLB instance when purchasing it.
    Vip No String Specifies a VIP for the CLB instance.
    • VpcId is optional for creating shared clusters of public network CLB instances. For IPv6 CLB instance type, SubnetId is required; for IPv4 and IPv6 NAT64 types, it can be left empty.
    • VpcId is optional for creating shared clusters of public network CLB instances. For IPv6 CLB instance type, SubnetId is required; for IPv4 and IPv6 NAT64 types, it can be left empty.
    BandwidthPackageId No String Bandwidth package ID. If this parameter is specified, the network billing mode (InternetAccessible.InternetChargeType) will only support bill-by-bandwidth package (BANDWIDTH_PACKAGE).
    ExclusiveCluster No ExclusiveCluster Exclusive cluster information. This parameter is required for creating exclusive clusters of CLB instances.
    SlaType No String
    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.
    SnatPro No Boolean Whether Binding IPs of other VPCs feature switch
    SnatIps.N No Array of SnatIp Creates SnatIp when the binding IPs of other VPCs feature is enabled
    ClusterTag No String Tag for the STGW exclusive cluster.
    SlaveZoneId No String Sets the secondary AZ ID for cross-AZ disaster recovery, such as 100001 or ap-guangzhou-1, which is applicable only to public network CLB instances.
    Note: A secondary AZ will load traffic if the primary AZ has failures. The API DescribeMasterZones is used to query the primary and secondary AZ list of a region.
    EipAddressId No String Unique ID of an EIP, which can only be used when binding the EIP of a private network CLB instance. E.g., eip-11112222.

    3. Output Parameters

    Parameter Name Type Description
    LoadBalancerIds Array of String Array of unique CLB instance IDs.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Creating a public network CLB instance

    This example shows you how to create a public network CLB instance in a VPC.

    Input Example

    https://clb.tencentcloudapi.com/?Action=CreateLoadBalancer
    &LoadBalancerType=OPEN
    &Forward=1
    &VpcId=vpc-30xqxt9p
    &LoadBalancerName=test
    &ProjectId=0
    &<Common request parameters>
    

    Output Example

    {
    "Response": {
      "LoadBalancerIds": [
        "lb-6efswuxa"
      ],
      "RequestId": "9b3f0b57-fb64-4918-8dd6-ce02604fb52c"
    }
    }
    

    Example2 Creating a private network CLB instance

    This example shows you how to create a private network CLB instance in a VPC.

    Input Example

    https://clb.tencentcloudapi.com/?Action=CreateLoadBalancer
    &LoadBalancerType=INTERNAL
    &Forward=1
    &LoadBalancerName=test_internal
    &VpcId=vpc-30xqxt9p
    &SubnetId=subnet-k57djpow
    &<Common request parameters>
    

    Output Example

    {
    "Response": {
      "LoadBalancerIds": [
        "lb-kmfrnqci"
      ],
      "RequestId": "7ffa6830-cd1b-4bc4-8e24-1688885f594a"
    }
    }
    

    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
    FailedOperation Operation failed.
    InternalError Internal error.
    InvalidParameter Parameter error.
    InvalidParameter.FormatError Wrong parameter format.
    InvalidParameterValue Incorrect parameter value.
    InvalidParameterValue.Length Wrong parameter length.
    InvalidParameterValue.Range Wrong parameter value range.
    LimitExceeded Quota exceeded.
    MissingParameter Missing parameter.
    ResourceInsufficient Insufficient resources.
    UnauthorizedOperation Unauthorized operation.