Creates a server group in a specified region.
Operation description
CreateServerGroup is an asynchronous operation. After you send a request, the system returns a request ID. The server group for the Network Load Balancer (NLB) instance is created in the background. You can call the GetJobStatus operation to query the creation status of the server group:
If the task status is Succeeded, the server group is created.
If the task status is Processing, the server group is being created. In this state, you can only perform query operations.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
nlb:CreateServerGroup |
create |
*ServerGroup
*VPC
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ServerGroupType |
string |
No |
The type of the server group. Valid values:
|
Instance |
| ServerGroupName |
string |
Yes |
The name of the server group. The name must be 2 to 128 characters in length and start with a letter. It can contain digits, periods (.), underscores (_), and hyphens (-). |
NLB_ServerGroup |
| AddressIPVersion |
string |
No |
The IP version. Valid values:
|
ipv4 |
| Protocol |
string |
No |
The traffic scheduling policy for dual-stack mode. Valid values:
Note
This parameter applies only when AddressIPVersion is set to DualStack. |
TCP |
| VpcId |
string |
Yes |
The protocol for forwarding requests to the backend servers. Valid values:
Note
|
vpc-bp15zckdt37pq72zv**** |
| AnyPortEnabled |
boolean |
No |
The ID of the VPC where the server group is located. Note
If ServerGroupType is set to Instance, only servers in this VPC can be added to the server group. |
false |
| ConnectionDrainEnabled |
boolean |
No |
Specifies whether to enable all-port forwarding. Valid values:
|
false |
| ConnectionDrainTimeout |
integer |
No |
Specifies whether to enable connection draining. Valid values:
|
10 |
| Scheduler |
string |
No |
The connection draining timeout, in seconds. The value must be from 0 to 900. |
Wrr |
| PreserveClientIpEnabled |
boolean |
No |
The scheduling algorithm. Valid values:
Note
QUIC ID hash is supported only when the backend protocol is UDP. |
true |
| HealthCheckConfig |
object |
No |
Specifies whether to enable client IP persistence. Valid values:
Note
If Protocol is set to TCP and this parameter is set to true, the server group cannot be associated with a TCPSSL listener. |
|
| HealthCheckEnabled |
boolean |
No |
|
true |
| HealthCheckType |
string |
No |
|
TCP |
| HealthCheckConnectPort |
integer |
No |
|
0 |
| HealthyThreshold |
integer |
No |
|
2 |
| UnhealthyThreshold |
integer |
No |
|
2 |
| HealthCheckConnectTimeout |
integer |
No |
|
5 |
| HealthCheckInterval |
integer |
No |
|
5 |
| HealthCheckDomain |
string |
No |
|
$SERVER_IP |
| HealthCheckUrl |
string |
No |
|
/test/index.html |
| HealthCheckHttpCode |
array |
No |
|
|
|
string |
No |
|
http_2xx |
|
| HttpCheckMethod |
string |
No |
|
GET |
| HealthCheckReq |
string |
No |
|
hello |
| HealthCheckExp |
string |
No |
|
ok |
| HealthCheckHttpVersion |
string |
No |
|
HTTP1.0 |
| ResourceGroupId |
string |
No |
The health check configuration. |
rg-atstuj3rtop**** |
| DryRun |
boolean |
No |
The ID of the resource group to which the server group belongs. |
true |
| ClientToken |
string |
No |
Specifies whether to perform a dry run. Valid values:
|
123e4567-e89b-12d3-a456-426655440000 |
| RegionId |
string |
No |
The client token used to ensure the idempotence of the request. Generate a value from your client. Ensure that the value is unique for each request. The ClientToken parameter supports only ASCII characters. Note If you do not specify this parameter, the system uses the RequestId of the API request as the ClientToken. The RequestId is unique for each API request. |
cn-hangzhou |
| Tag |
array<object> |
No |
The ID of the region where the Network Load Balancer (NLB) instance is deployed. Call the DescribeRegions operation to get the region ID. |
|
|
object |
No |
|
||
| Key |
string |
No |
|
env |
| Value |
string |
No |
|
product |
| IpVersionAffinityMode |
string |
No |
The tags. |
Affinity |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The server group is created. |
||
| RequestId |
string |
The request ID. |
54B48E3D-DF70-471B-AA93-08E683A1B45 |
| ServerGroupId |
string |
The server group ID. |
sgp-atstuj3rtoptyui**** |
| JobId |
string |
The ID of the asynchronous task. |
72dcd26b-f12d-4c27-b3af-18f6aed5**** |
Examples
Success response
JSON format
{
"RequestId": "54B48E3D-DF70-471B-AA93-08E683A1B45",
"ServerGroupId": "sgp-atstuj3rtoptyui****",
"JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | IllegalParam.AnyPortServerGroupConflictWithHealthCheckConfig | The param of AnyPortServerGroupConflictWithHealthCheckConfig is illegal. | |
| 400 | IllegalParamFormat.ParseCreateRsPoolRequestFailed | The param format of CreateRsPoolRequest is illegal. | The param format of CreateRsPoolRequest is illegal. |
| 400 | IllegalParam.PreserveClientIpSwitch | The param of PreserveClientIpSwitch is illegal. | |
| 400 | OperationDenied.VpcNotSupportIpv6 | The operation is not allowed because of VpcNotSupportIpv6. | The VPC you are using does not support Ipv6. |
| 400 | IllegalParam.healthCheckDomain | The parameter of healthCheckConfig.healthCheckDomain is illegal. | The healthCheckDomain in the health check configuration is invalid. Check the input parameters. |
| 400 | OperationDenied.UidNotAllowQuic29 | The operation is not allowed because of uid not allow quic29 version. | |
| 400 | IlleagalParam.healthCheckUrl | The parameter of healthCheckUrl in healthCheckConfig is illegal. | The URL of the health check used in the health check setting is invalid. |
| 400 | IllegalParam.ServerGroupName | The param of ServerGroupName is illegal. | |
| 400 | DryRunOperation | Request validation has been passed with DryRun flag set. | Request validation has been passed with DryRun flag set. |
| 400 | MissingParam.%s | The parameter of %s is missing. | |
| 400 | IllegalParam.ConnectionDrainTimeout | The param of ConnectionDrainTimeout is illegal. | The parameter ConnectionDrainTimeout is invalid. Check the input parameters. |
| 400 | IllegalParam | The param of %s is illegal. | |
| 400 | SystemBusy | System is busy, please try again later. | |
| 400 | QuotaExceeded.QuotaInsufficient | The 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. |
| 403 | Forbidden.NoPermission | Authentication is failed for NoPermission. | Authentication is failed for NoPermission. |
| 404 | ResourceNotFound.Vpc | The specified resource of Vpc is not found. | The specified VPC resource was not found. Please check the input parameters. |
| 404 | ResourceNotFound.ResourceGroup | The param of resourceGroup not existed. | The resource group does not exist. |
See for a complete list.
Release notes
See Release Notes for a complete list.