CreateLoadBalancer
1. API Description
This API (CreateLoadBalancer) is used to create a load balancer instance.
2. Input Parameters
The following request parameter list only provides API request parameters.
loadBalancerName
Yes
String
Load balance instance name.
Containing 1 to 64 characters.
Available range: [1.0, +).
Value range: [1.0, +)
vpcId
No
String
ID of the VPC to which the backend servers of the load balancer belong.
At least one of vpcId and subnetId must be specified.
If only subnetId is specified, the VPC to which the subnet belongs is used.
It can be obtained by calling DescribeVpcs.
subnetId
No
String
Subnet ID.
It can be obtained by calling DescribeSubnets.
At least one of vpcId and subnetId must be specified.
The subnet must be in the same region as regionId; if vpcId is also specified, the subnet must belong to that VPC.
When ipStackType is IPv4, the subnet must support IPv4 and is used to allocate the health check private IPs; this parameter is optional (the system selects one within the VPC). When ipStackType is IPv6, this parameter only indicates the source subnet of the public IPv6: it is required when internetChargeType is specified, and the subnet must contain a public IPv6 block (a private IPv6 block does not qualify); MISSING_PARAMETER is returned if it is not specified. It does not take effect when internetChargeType is not specified.
privateIpSubnetId
No
String
ID of the source subnet of the private VIP.
It can be obtained by calling DescribeSubnets.
If specified, 1 private VIP is automatically allocated from this subnet to each load balancer instance at creation; if not specified, no private VIP is allocated at creation, and you can call AddLoadBalancersPrivateIps to add one after creation.
The subnet must support IPv4, be in the same region as regionId, and belong to the VPC of the load balancer.
Can only be specified when ipStackType is IPv4.
The region specified by regionId must support load balancer private IPs. You can call DescribeLoadBalancerRegions to check supportPrivateIp; OPERATION_DENIED_LB_REGION_NOT_SUPPORT_PRIVATE_IP is returned if it is not supported.
Private VIPs and public IPs together count against the VIP quota of a single load balancer.
healthCheckPrivateIps
No
Array of String
Health probe source private IP addresses; the quantity must be 2.
When subnetId is specified and this field is left empty, 2 available private IPv4 addresses are randomly allocated from that subnet as the health probe source IPs. Each load balancer instance occupies 2 addresses; if the subnet does not have enough available private IPv4 addresses remaining, INVALID_SUBNET_IPV4_INSUFFICIENT is returned. The allocation result can be queried by calling DescribeLoadBalancers.
When subnetId is not specified, this parameter is invalid.
It can be specified only when ipStackType is IPv4. When ipStackType is IPv6, the health probe block is automatically allocated by the system from the public IPv6 block of the subnet, and specifying this parameter returns INVALID_PARAMETER_CONFLICT.
ipStackType
No
IP stack type.
A load balancer instance supports only a single stack, that is, IPv4 or IPv6. Dual stack is not supported.
When IPv6 is specified: specifying internetChargeType means that 1 public IPv6 block is assigned to each instance at creation, and the line is fixed to BGP. In this case, subnetId is required and networkLineType cannot be specified. If internetChargeType is not specified, no public IPv6 is assigned at creation, and you can assign one later through AssignLoadBalancerIpv6.
eipIds cannot be specified for IPv6, because all EIPs are IPv4.
Default value: IPv4
eipIds
No
Array of String
List of IDs of existing elastic IPs to be associated with the new load balancer instance.
Both single-IP EIPs (mask /32) and block-type EIPs are supported. You can call DescribeEips to query them.
All EIPs must be in the same region as regionId and in the unassociated state.
When this parameter is specified, internetChargeType, networkLineType, bandwidthMbps, trafficPackageSize, and bandwidthClusterId do not take effect, no new EIP is created for the instance, and number can only be 1.
It can be specified only when ipStackType is IPv4.
internetChargeType
No
IP network billing method.
This parameter does not take effect when eipIds is specified.
When ipStackType is IPv6, it applies to the public IPv6 assigned at creation.
networkLineType
No
IP network type.
Can only be specified when ipStackType is IPv4. The line of IPv6 is fixed to BGP; specifying this parameter returns INVALID_PARAMETER_CONFLICT.
bandwidthMbps
No
Integer
Maximum outbound bandwidth of the elastic IP. Unit: Mbps. The maximum limit is usually 10000 Mbps. If you have additional requirements, please contact Support. This parameter is required when internetChargeType is ByBandwidth.
Value range: [1, +)
trafficPackageSize
No
Float
Traffic package size.
When this parameter is specified, the IP network billing method (internetChargeType) must be ByTrafficPackage; otherwise this parameter does not take effect.
It can only be set when the billing period is monthly; hourly billing is not supported.
Value range: [0.0, 999999.0]
bandwidthClusterId
No
String
Bandwidth cluster ID.
When this parameter is specified, the IP network billing method (internetChargeType) must be BandwidthCluster; otherwise this parameter does not take effect.
resourceGroupId
No
String
Resource Group ID
If not specified, the load balance instance will belong to the default resource group.
number
No
Integer
The number of created load balancers.
Default value: 1
securityGroupId
No
String
ID of the security group associated with the load balancer instance.
It can be obtained by calling DescribeSecurityGroups.
3. Output Parameters
requestId
String
The unique request ID, which is returned for each request.
RequestId is required for locating a problem.
orderNumber
String
Order number.
loadBalancerIds
Array of String
A collection of unique IDs of the load balancer instances.
4. Code Example
1. Create a public load balancer instance. The IP billing method is fixed bandwidth.
2. Specify only subnetId without vpcId: the load balancer instance belongs to the VPC of the subnet, and 2 private IPv4 addresses are randomly allocated from the subnet as the health check source IPs.
3. Create a load balancer instance with an existing elastic IP (EIP) instead of creating a new EIP.
4. Create a load balancer instance with a POC voucher. If no POC voucher exists in the system, the creation will fail.
5. Create an IPv6 load balancer instance and assign 1 public IPv6 at the same time. The network billing method is fixed bandwidth, and the line is fixed to BGP, so networkLineType does not need to be specified.
6. Create an IPv6 load balancer instance without assigning a public IPv6 for now. subnetId does not need to be specified.
5. Developer Resources
Zenlayer Cloud API 2.0 integrates SDKs,to make it easier for you to call APIs. More programming languages will be supported.
6. Error Codes
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
404
INVALID_EIP_NOT_FOUND
Elastic IP does not exist.
400
INVALID_IP_BROADCAST_ADDRESS
Invalid IP address: broadcast addresses are not allowed.
400
INVALID_IP_FIRST_ADDRESS
Invalid IP address: gateway addresses are not allowed.
400
INVALID_IP_NETWORK_ADDRESS
Invalid IP address: network addresses are not allowed.
400
INVALID_IP_OUT_OF_RANGE
Invalid IP address: not within the CIDR range.
400
INVALID_LB_SUBNET_REGION_MISMATCH
The subnet of the load balancer private IP is not in the same region as the load balancer.
400
INVALID_REGION_MISMATCH
The EIP is not in the same region as the target resource.
404
INVALID_REGION_NOT_FOUND
Specified region does not exist.
404
INVALID_SECURITY_GROUP_NOT_FOUND
Security group does not exist.
409
INVALID_SUBNET_IPV4_INSUFFICIENT
There are not enough available IPv4 addresses in the subnet.
409
INVALID_SUBNET_IPV6_INSUFFICIENT
The number of the available IPv6 addresses in the subnet is insufficient.
400
INVALID_SUBNET_NOT_BELONG_TO_VPC
Specified subnet is not within the global VPC.
404
INVALID_SUBNET_NOT_FOUND
Subnet does not exist.
409
INVALID_SUBNET_PRIVATE_IPV4_IN_USED
Preset private IP is already be used.
404
INVALID_VPC_NOT_FOUND
Global VPC does not exist.
400
OPERATION_DENIED_EIP_ASSIGNED_LIMIT_EXCEEDED
Elastic IP binding exceeds the allowed limit.
400
OPERATION_DENIED_EIP_INSUFFICIENT
Insufficient elastic IP addresses. Operation failed.
400
OPERATION_DENIED_EIP_IS_DEFAULT
Default public IP cannot be unbound.
400
OPERATION_DENIED_EIP_IS_NOT_UN_ASSIGN
The EIP is already occupied (not in the unbound state) and cannot be bound.
400
OPERATION_DENIED_EIP_QUOTA_LIMIT_EXCEEDED
The number of elastic IP addresses exceeds limit.
500
OPERATION_DENIED_EIP_STATUS_NOT_SUPPORT
The current EIP status does not support this operation.
400
OPERATION_DENIED_LB_REGION_NOT_SUPPORT_PRIVATE_IP
The region of the load balancer does not support private IPs.
400
OPERATION_DENIED_SUBNET_TYPE_NOT_SUPPORT
Subnet stack type is not supported.
400
OPERATION_DENIED_SUBNET_TYPE_NOT_SUPPORT_IPV4
IPv4 subnet stack type is not supported.
400
OPERATION_DENIED_SUBNET_NOT_SUPPORT_PUBLIC_IPV6
The subnet does not have a public IPv6 block.
409
OPERATION_DENIED_NO_AVAILABLE_SUBNET
No valid subnet exists under the global VPC. Operation failed.
400
INVALID_PARAMETER_FLOW_PACKAGE_NOT_SUPPORTED_FOR_PATH_BASED
PathBasedBandwidthIP does not support a custom traffic package size. Pass 0 or omit this parameter.
400
OPERATION_DENIED_FIXED_BANDWIDTH_NOT_SUPPORTED_FOR_PATH_BASED
PathBasedBandwidthIP does not support fixed bandwidth billing.
400
OPERATION_DENIED_FLOW_PACKAGE_NOT_SUPPORTED_HOUR_PERIOD
The current product cycle is based on hourly billing and does not support setting a minimum data package size.
400
INVALID_PARAMETER_BANDWIDTH_ERROR
The bandwidth limit value is below the minimum limit.
400
INVALID_PARAMETER_BANDWIDTH_EXCEED
The bandwidth limit value exceeds the maximum limit.
400
OPERATION_DENIED_EIP_INTERNET_CHARGE_TYPE_NOT_AVAILABLE
The specified IP network line type in this node does not support this network billing method.
400
OPERATION_DENIED_EIP_NETWORK_LINE_TYPE_NOT_ON_SALE
The IP network line type is not available for sale in this node.
Last updated