Creates a Server Load Balancer (SLB) instance.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateLoadBalancer

The operation that you want to perform.

Set the value to CreateLoadBalancer.

ClientToken String No 5A2CFF0E-5718-45B5-9D4D-70B3FF3898

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that it is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

DryRun Boolean No true

Specifies whether to precheck the API request. Valid values:

true: only prechecks the API request. If you select this option, the specified endpoint service is not created after the request passes the precheck. The system prechecks the required parameters, request format, and service limits. If the request fails the precheck, the corresponding error message is returned. If the request passes the precheck, the DryRunOperation error code is returned.

false: checks the request. After the request passes the check, an HTTP_2xx status code is returned and the operation is performed. This is the default value.

VpcId String Yes vpc-2423****

The ID of the virtual private cloud (VPC) where the SLB instance is deployed.

AddressType String Yes Internet

The type of IP address that the SLB instance uses to provide services.

  • Internet: The SLB instance uses a public IP address to resolve domain names and can be accessed from the Internet.
  • Intranet: The SLB instance uses a private IP address to resolve domain names and can only be accessed from the VPC where the instance is deployed.
LoadBalancerName String No alb1

The name of the SLB instance.

The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

DeletionProtectionEnabled Boolean No false

Specifies whether deletion protection is enabled.

Valid values: true and false.

Default value: false.

ModificationProtectionConfig Object No

The configuration of modification protection.

Reason String No ManageInstance

The reason for modification protection must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The reason must start with a letter.

This parameter is required only if ModificationProtectionStatus is set to ConsoleProtection.

Status String No ConsoleProtection

Specifies whether to enable the configuration read-only mode for the SLB instance:

  • NonProtection: disables the configuration read-only mode. After you disable the configuration read-only mode, you cannot set the ModificationProtectionReason parameter. If the parameter is set, the value is cleared.
  • NonProtection: enables the configuration read-only mode. After you enable the configuration read-only mode, you can set the ModificationProtectionReason parameter.
ZoneMappings Array Yes

The zones and vSwitches. You must specify at least two zones.

VSwitchId String Yes vsw-sersdf****

The ID of the vSwitch that corresponds to the zone. Each zone can use only one vSwitch and subnet.

ZoneId String Yes cn-hangzhou-a

The ID of the zone to which the SLB instance belongs.

AddressAllocatedMode String No Fixed

The type of IP address used by the SLB instance. Valid values:

  • Fixed: The SLB instance uses a fixed IP address.
  • Dynamic: One or more IP addresses are allocated for the SLB instance to use in each zone. This is the default value.
ResourceGroupId String No rg-atstuj3rtop****

The ID of the enterprise resource group.

LoadBalancerEdition String Yes Standard

The edition of the SLB instance. Different editions have different limits and billing methods.

  • Basic: Basic Edition.
  • Standard: Standard Edition.
LoadBalancerBillingConfig Object Yes

The configuration of the billing method.

PayType String Yes PostPay

The billing method of the SLB instance.

If you set the value to PostPay, the instance is billed based on the pay-as-you-go method.

Response parameters

Parameter Type Example Description
LoadBalancerId String lb-bp1o94dp5i6ea****

The ID of the SLB instance.

RequestId String CEF72CEB-54B6-4AE8-B225-F876FF7BA984

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateLoadBalancer
&ClientToken=5A2CFF0E-5718-45B5-9D4D-70B3FF3898
&DryRun=true
&VpcId=vpc-2423****
&AddressType=Internet
&LoadBalancerName=alb1
&DeletionProtectionEnabled=false
&ModificationProtectionConfig={"Reason":"ManageInstance","Status":"ConsoleProtection"}
&ZoneMappings=[{"VSwitchId":"vsw-sersdf****","ZoneId":"cn-hangzhou-a"}]
&AddressAllocatedMode=Fixed
&ResourceGroupId=rg-atstuj3rtop****
&LoadBalancerEdition=Standard
&LoadBalancerBillingConfig={"PayType":"PostPay"}
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateLoadBalancerResponse>
    <LoadBalancerId>lb-bp1o94dp5i6ea****</LoadBalancerId>
    <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
</CreateLoadBalancerResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "LoadBalancerId" : "lb-bp1o94dp5i6ea****",
  "RequestId" : "CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
}

Error codes

HttpCode Error code Error message Description
400 ResourceNotEnough.VSwitchIp The specified resource %s is not enough. The error message returned because the specified resource is insufficient.
400 QuotaExceeded.LoadBalancersNum The quota of %s is exceeded, usage %s/%s. The error message returned because the usage %s has exceeded the quota %s.
400 Mismatch.ZoneIdAndVSwitchId The %s and %s are mismatched. The error message returned because %s does not correspond to %s.
404 ResourceNotFound.VSwitch The specified resource %s is not found. The error message returned because the specified resource %s does not exist.
404 ResourceNotFound.Vpc The specified resource %s is not found. The error message returned because the specified resource %s does not exist.

For a list of error codes, visit the API Error Center.