CreateLoadBalancer

Updated at: 2025-03-21 03:47

Creates a Network Load Balancer (NLB) instance in a specified region.

Operation description

  • When you create an NLB instance, the service-linked role AliyunServiceRoleForNlb is automatically created and assigned to you.

  • CreateLoadBalancer is an asynchronous operation. After you send a request, the system returns an instance ID and runs the task in the background. You can call GetLoadBalancerAttribute to query the status of an NLB instance.

    • If an NLB instance is in the Provisioning state, the NLB instance is being created.
    • If an NLB instance is in the Active state, the NLB instance is created.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
OperationAccess levelResource typeCondition keyAssociated operation
nlb:CreateLoadBalancercreate
*LoadBalancer
acs:nlb:{#regionId}:{#accountId}:loadbalancer/*
*VSwitch
acs:vpc:{#regionId}:{#accountId}:vswitch/{#VSwitchId}
EipAddress
acs:vpc:{#regionId}:{#accountId}:eip/{#AllocationId}
*VPC
acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ParameterTypeRequiredDescriptionExample
LoadBalancerTypestringNo

The type of the Server Load Balancer (SLB) instance. Set the value to network, which specifies NLB.

network
LoadBalancerNamestringNo

The name of the NLB instance.

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

NLB1
AddressTypestringYes

The type of the IPv4 address used by the NLB instance. Valid values:

  • Internet: The NLB instance uses a public IP address. The domain name of the instance is resolved to the public IP address. The instance is accessible over the Internet.
  • Intranet: The NLB instance uses a private IP address. The domain name of the instance is resolved to the private IP address. The instance is accessible only within the virtual private cloud (VPC) where the instance is deployed.
Note
To enable a public IPv6 address for a dual-stack NLB instance, call the EnableLoadBalancerIpv6Internet operation.
Internet
AddressIpVersionstringNo

The IP version of the NLB instance. Valid values:

  • ipv4 (default): IPv4
  • DualStack: dual-stack
ipv4
VpcIdstringYes

The ID of the VPC where you want to create the NLB instance.

vpc-bp1b49rqrybk45nio****
ZoneMappingsarray<object>Yes

The mappings between zones and vSwitches. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, you must specify at least two zones.

ZoneMappingobjectYes

The mapping between the zone and the vSwitch. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, you must specify at least two zones.

VSwitchIdstringYes

The ID of the vSwitch in the zone. You can specify only one vSwitch (subnet) in each zone of an NLB instance. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, you must specify at least two zones.

vsw-sersdf****
ZoneIdstringYes

The ID of the zone where the NLB instance is deployed. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, specify at least two zones.

You can call the DescribeZones operation to query the most recent zone list.

cn-hangzhou-a
PrivateIPv4AddressstringNo

The private virtual IP address (VIP) of the IPv4 version. The private IPv4 address that the NLB instance uses to provide external services.

192.168.10.1
AllocationIdstringNo

The ID of the elastic IP address (EIP) that is associated with the Internet-facing NLB instance. Each zone is assigned one EIP. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, specify at least two zones.

eip-bp1aedxso6u80u0qf****
Ipv6AddressstringNo

The VIP of the IPv6 version. The IPv6 address that the NLB instance uses to provide external services.

2408:400a:d5:3080:b409:840a:ca:e8e5
Ipv4LocalAddressesarrayNo

The local IPv4 addresses. The IP addresses that the NLB instance uses to communicate with the backend servers. The number of IP addresses must be an even number, which must be at least 2 and at most 8.

stringNo

The local IPv4 address.

192.168.10.2
Ipv6LocalAddressesarrayNo

The local IPv6 addresses. The IP addresses that the NLB instance uses to communicate with the backend servers. The number of IP addresses must be an even number, which must be at least 2 and at most 8.

stringNo

The local IPv6 address.

2408:400a:d5:3080:b409:840a:ca:e8e6
BandwidthPackageIdstringNo

The ID of the Internet Shared Bandwidth instance that is associated with the Internet-facing NLB instance.

cbwp-bp1vevu8h3ieh****
LoadBalancerBillingConfigobjectNo

The billing settings of the NLB instance.

PayTypestringNo

The billing method of the NLB instance.

Set the value to PostPay, which specifies the pay-as-you-go billing method.

PostPay
ResourceGroupIdstringNo

The ID of the resource group to which the instance belongs.

rg-atstuj3rtop****
DryRunbooleanNo

Specifies whether to perform a dry run. Valid values:

  • true: validates the request without performing the operation. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, and service limits. If the request fails the validation, the corresponding error message is returned. If the request passes the validation, the DryRunOperation error code is returned.
  • false (default): validates the request and performs the operation. If the request passes the validation, a 2xx HTTP status code is returned and the operation is performed.
false
ClientTokenstringNo

The client token used to ensure the idempotence of the request.

You can use the client to generate the token. Ensure that the token is unique among different requests. Only ASCII characters are allowed.

Note
If you do not specify this parameter, the value of RequestId is used.**** The value of RequestId is different for each request.
123e4567-e89b-12d3-a456-426655440000
RegionIdstringNo

The ID of the region where the NLB instance is deployed.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
DeletionProtectionConfigobjectNo

The configuration of the deletion protection feature.

EnabledbooleanNo

Specifies whether to enable the deletion protection feature. Valid values:

  • true
  • false (default)
false
ReasonstringNo

The reason why the deletion protection feature is enabled or disabled. The reason must be 2 to 128 characters in length, can contain letters, digits, periods (.), underscores (_), and hyphens (-), and must start with a letter.

The instance is running
ModificationProtectionConfigobjectNo

The configuration of the configuration read-only mode.

StatusstringNo

Specifies whether to enable the configuration read-only mode. Valid values:

  • NonProtection: does not enable the configuration read-only mode. You cannot set the Reason parameter. If the Reason parameter is set, the value is cleared.
  • ConsoleProtection: enables the configuration read-only mode. You can set the Reason parameter.
Note
If the parameter is set to ConsoleProtection, the configuration read-only mode is enabled. You cannot modify the configurations of the NLB instance in the NLB console. However, you can call API operations to modify the configurations of the NLB instance.
ConsoleProtection
ReasonstringNo

The reason for enabling the configuration read-only mode. The reason must be 2 to 128 characters in length, can contain letters, digits, periods (.), underscores (_), and hyphens (-), and must start with a letter.

Note
This parameter takes effect only when Status is set to ConsoleProtection.
Service guarantee period
Tagarray<object>No

The tags.

objectNo

The tag.

KeystringNo

The key of the tag. The tag key can be up to 64 characters in length, cannot start with aliyun or acs:, and cannot contain http:// or https://. The tag key can contain letters, digits, and the following special characters: _ . : / = + - @

You can specify up to 20 tags in each call.

env
ValuestringNo

The value of the tag. The tag value can be up to 128 characters in length, cannot start with acs: or aliyun, and cannot contain http:// or https://. The tag value can contain letters, digits, and the following special characters: _ . : / = + - @

You can specify up to 20 tags in each call.

product

Response parameters

ParameterTypeDescriptionExample
ParameterTypeDescriptionExample
object

response

RequestIdstring

The ID of the request.

CEF72CEB-54B6-4AE8-B225-F876FF7BA984
LoadbalancerIdstring

The ID of the NLB instance.

nlb-83ckzc8d4xlp8o****
OrderIdlong

The ID of the order for the NLB instance.

20230000

Examples

Sample success responses

JSONformat

{
  "RequestId": "CEF72CEB-54B6-4AE8-B225-F876FF7BA984",
  "LoadbalancerId": "nlb-83ckzc8d4xlp8o****",
  "OrderId": 20230000
}

Error codes

HTTP status codeError codeError messageDescription
HTTP status codeError codeError messageDescription
400OperationDenied.OnlyPayByTrafficSupportedThe operation is not allowed because of OnlyPayByTrafficSupported.-
400OperationFailed.%sThe operation failed because of %s.Failed to call the API operation due to %.
400Mismatch.ZoneIdAndVswitchIdThe ZoneIdAndVswitchId is mismatched for %s and %s.-
400QuotaExceeded.%sThe quota of %s is exceeded, usage %s/%s.-
400DryRunOperationRequest validation has been passed with DryRun flag set.Request validation has been passed with DryRun flag set.
400OperationDenied.OnlyPostPaidSupportedThe operation is not allowed because of OnlyPostPaidSupported.-
400OperationFailed.DuplicateZones.The operation failed because of Can not Specify duplicate zones.-
400ResourceNotEnough.VSwitchIpThe specified resource of VSwitchIp is not enough.The specified virtual switch (vSwitch) IP resources are insufficient.
400DuplicatedParam.AllocationIdThe param of AllocationId is duplicated.-
400ResourceInConfiguring.VswitchIdThe specified resource of VswitchId is being configured, please try again later.The specified resource of VswitchId is being configured, please try again later.
400IllegalParamThe param of %s is illegal.-
400OperationFailed.UnpaidBillThe operation failed because of UnpaidBill.-
400OperationDenied.ServiceLinkedRoleNotExistThe operation is not allowed because of ServiceLinkedRoleNotExist.The operation is not allowed because of ServiceLinkedRoleNotExist.Please check if the necessary permissions are granted in RAM for the NLB.
400ResourceAlreadyAssociated.AllocationIdThe specified resource of %s is already associated.-
400OperationFailed.vSwitchNotSupportIpv6The operation failed because of vSwitchNotSupportIpv6.-
400InvalidZonesThe current zone list is illegal.The Availability Zone used in Zone maping is illegal.
400QuotaExceeded.QuotaInsufficientThe quota of %s is exceeded, usage %s/%s.The quota is insufficient, currently used %s/%s. Please modify the quota size in the quota center.
400ResourceInUse.IPThe specified resource of IP is in use.-
400OperationFailed.CreateOrderErrorOperation failed because CreateOrderError.The operation failed because the order creation failed.
400OperationFailed.NotExist.ResourceGroupOperation failed because ResourceGroup not exist.The specified resource group does not exist.
400IllegalParam.loadBalancerNameParam loadBalancerName is illegal.The instance name is invalid. Check the parameters.
400SystemBusySystem is busy, please try again later.-
400MissingParam.%sThe parameter of %s is missing.-
400IllegalParam.loadBalancerNameThe parameter loadBalancerName of listener is illegal.The NLB instance name does not meet the input requirements, please modify according to the details in the error.
400IllegalParam.DeletionProtectionConfigDeletionProtectionConfig reason is illegal.The reason parameter for changing the delete protection status is invalid.
400IllegalParam.ModificationProtectionConfigModificationProtectionConfig reason is illegal.ModificationProtectionConfig reason is illegal.
400Throttling.UserRequest was denied due to api flow control.Request was denied due to api flow control.
403UnauthorizedZoneThe specified zone of %s is not authorized.-
403Forbidden.NoPermissionAuthentication is failed for NoPermission.Authentication is failed for NoPermission.
403UnauthorizedRegionThe specified region of %s is not authorized.-
404ResourceNotFound.VSwitchThe specified resource of vSwitch is not found.The specified vSwitch resource was not found. Please check the input parameters.
404ResourceNotFound.VpcThe specified resource of Vpc is not found.The specified VPC resource was not found. Please check the input parameters.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
Change timeSummary of changesOperation
2024-09-06The Error code has changedView Change Details
2024-09-04The Error code has changedView Change Details
2024-02-04The Error code has changedView Change Details
2024-02-04The Error code has changedView Change Details
2024-02-04The Error code has changedView Change Details
2024-01-22The Error code has changedView Change Details
2023-12-20The Error code has changedView Change Details
2023-11-27The Error code has changedView Change Details
2023-10-09The Error code has changedView Change Details
2023-09-26The Error code has changedView Change Details
2023-09-12The Error code has changedView Change Details
2023-09-08The Error code has changedView Change Details
2023-09-05The Error code has changedView Change Details
2023-08-22The Error code has changedView Change Details
2023-06-30The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-06-29The request parameters of the API has changedView Change Details
  • On this page (1)
  • Operation description
  • Debugging
  • Authorization information
  • Request parameters
  • Response parameters
  • Examples
  • Error codes
  • Change history
Feedback
phone Contact Us