Creates a server group in a specified region.
Operation description
CreateServerGroup is an asynchronous operation. After a request is sent, the system returns a request ID. However, the server group is still being created in the background. You can call the GetJobStatus operation to query the creation status of a server group.
If a server group is in the Succeeded state, it is created.
If a server group is in the Processing state, it 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 server group. Valid values:
|
Instance |
| ServerGroupName |
string |
Yes |
The name of the server group. The name must be 2 to 128 characters in length, start with a letter or a Chinese character, and can contain digits, periods (.), underscores (_), and hyphens (-). |
NLB_ServerGroup |
| AddressIPVersion |
string |
No |
The protocol version. Valid values:
|
ipv4 |
| Protocol |
string |
No |
The protocol used to forward requests to the backend servers. Valid values:
Note
|
TCP |
| VpcId |
string |
Yes |
The ID of the virtual private cloud (VPC) to which the server group belongs. Note
If ServerGroupType is set to Instance, only servers in this VPC can be added to the server group. |
vpc-bp15zckdt37pq72zv**** |
| AnyPortEnabled |
boolean |
No |
Specifies whether to enable port forwarding for all ports. Valid values:
|
false |
| ConnectionDrainEnabled |
boolean |
No |
Specifies whether to enable connection draining. Valid values:
|
false |
| ConnectionDrainTimeout |
integer |
No |
The timeout period of connection draining. Unit: seconds. Valid values: 0 to 900. |
10 |
| Scheduler |
string |
No |
The scheduling algorithm. Valid values:
Note
You can set the value to qch only when the backend protocol is UDP. |
Wrr |
| PreserveClientIpEnabled |
boolean |
No |
Specifies whether to preserve client IP addresses. Valid values:
Note
If Protocol is set to TCP and this parameter is set to true, the server group cannot be associated with TCP over SSL listeners. |
true |
| HealthCheckConfig |
object |
No |
The health check settings. |
|
| HealthCheckEnabled |
boolean |
No |
Specifies whether to enable health checks. Valid values:
|
true |
| HealthCheckType |
string |
No |
The health check protocol. Valid values:
|
TCP |
| HealthCheckConnectPort |
integer |
No |
The port that is used for health checks on backend servers. Valid values: 0 to 65535. Default value: 0. This value indicates that the port of a backend server is used for health checks. |
0 |
| HealthyThreshold |
integer |
No |
The number of consecutive successful health checks required to change the health status of a backend server from failed to successful. Valid values: 2 to 10. Default value: 2. |
2 |
| UnhealthyThreshold |
integer |
No |
The number of consecutive failed health checks required to change the health status of a backend server from successful to failed. Valid values: 2 to 10. Default value: 2. |
2 |
| HealthCheckConnectTimeout |
integer |
No |
The maximum timeout period of a health check response. Unit: seconds. Valid values: 1 to 300. Default value: 5. |
5 |
| HealthCheckInterval |
integer |
No |
The interval between two consecutive health checks. Unit: seconds. Default value: 5.
|
5 |
| HealthCheckDomain |
string |
No |
The domain name that is used for health checks. Valid values:
Note
This parameter takes effect only when HealthCheckType is set to HTTP. |
$SERVER_IP |
| HealthCheckUrl |
string |
No |
The path that is used for health checks. The path must be 1 to 80 characters in length. It can contain letters, digits, and the following special characters: Note
This parameter takes effect only when HealthCheckType is set to HTTP. |
/test/index.html |
| HealthCheckHttpCode |
array |
No |
The HTTP status codes that indicate a healthy backend server. You can specify multiple HTTP status codes and separate them with commas (,). Valid values: http_2xx (default), http_3xx, http_4xx, and http_5xx. Note
This parameter takes effect only when HealthCheckType is set to HTTP. |
|
|
string |
No |
The HTTP status codes that indicate a healthy backend server. You can specify multiple HTTP status codes and separate them with commas (,). Valid values: http_2xx (default), http_3xx, http_4xx, and http_5xx. Note
This parameter takes effect only when HealthCheckType is set to HTTP. |
http_2xx |
|
| HttpCheckMethod |
string |
No |
The HTTP method that is used for health checks. Valid values: GET (default) and HEAD. Note
This parameter takes effect only when HealthCheckType is set to HTTP. |
GET |
| HealthCheckReq |
string |
No |
The request string for UDP health checks. The string can contain only letters and digits. The string must be at most 512 characters in length. |
hello |
| HealthCheckExp |
string |
No |
The response string for UDP health checks. The string can contain only letters and digits. The string must be at most 512 characters in length. |
ok |
| HealthCheckHttpVersion |
string |
No |
The version of the HTTP protocol. Valid values: HTTP1.0 (default) and HTTP1.1. Note
This parameter takes effect only when HealthCheckType is set to HTTP. |
HTTP1.0 |
| ResourceGroupId |
string |
No |
The ID of the resource group to which the server group belongs. |
rg-atstuj3rtop**** |
| DryRun |
boolean |
No |
Specifies whether to perform a dry run. Valid values:
|
true |
| ClientToken |
string |
No |
A client-generated token that is used to ensure the idempotence of the request. Make sure that the token is unique among different requests. The token can contain only ASCII characters. Note
If you do not specify this parameter, the system automatically uses the RequestId of the request as the ClientToken. The RequestId of each API request may be different. |
123e4567-e89b-12d3-a456-426655440000 |
| RegionId |
string |
No |
The ID of the region where the Network Load Balancer (NLB) instance is deployed. You can call the DescribeRegions operation to obtain region IDs. |
cn-hangzhou |
| Tag |
array<object> |
No |
The tags. |
|
|
object |
No |
The tag. |
||
| Key |
string |
No |
The key of the tag. The key can be up to 64 characters in length. It cannot start with You can add up to 20 tags in a single call. |
env |
| Value |
string |
No |
The value of the tag. The value can be up to 128 characters in length. It cannot start with You can add up to 20 tags in a single call. |
product |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
A server group is created. |
||
| RequestId |
string |
The ID of the request. |
54B48E3D-DF70-471B-AA93-08E683A1B45 |
| ServerGroupId |
string |
The ID of the server group. |
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 Error Codes for a complete list.
Release notes
See Release Notes for a complete list.