Associates a security group with a Network Load Balancer (NLB) instance.

Usage notes

  • Make sure that you have created a security group. For more information about how to create a security group, see CreateSecurityGroup.
  • An NLB instance can be associated with up to four security groups.
  • You can query the security groups that are associated with an NLB instance by calling the GetLoadBalancerAttribute operation.
  • LoadBalancerJoinSecurityGroup is an asynchronous operation. After you call the operation, the system returns a request ID and runs the task in the background. You can call the GetJobStatus operation to query the status of a task.
    • If the task is in the Succeeded state, the security group is associated.
    • If the task is in the Processing state, the security group is being associated. In this case, you can perform only query operations.

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 LoadBalancerJoinSecurityGroup

The operation that you want to perform. Set the value to LoadBalancerJoinSecurityGroup.

SecurityGroupIds.N String No sg-bp1fg655nh68xyz9****

The ID of the security group.

LoadBalancerId String Yes nlb-83ckzc8d4xlp8o****

The ID of the NLB instance to be associated with the security group.

DryRun Boolean No true

Specifies whether to check the request without performing the operation. Valid values:

  • true: checks the request without performing the operation. The system checks the required parameters, request syntax, and limits. If the request fails the check, an error code is returned based on the cause of the failure. If the request passes the check, the DryRunOperation error code is returned.
  • false (default): sends the request. If the request passes the check, an HTTP 2xx status code is returned and the operation is performed.
ClientToken String No 123e4567-e89b-12d3-a456-426655440000

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 the value is unique among different requests. The client token can contain only ASCII characters.

Note If you do not set this parameter, the system automatically uses the value of RequestId as the value of ClientToken. The value of RequestId may be different for each API request.
RegionId String No cn-hangzhou

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

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

Response parameters

Parameter Type Example Description
RequestId String CEF72CEB-54B6-4AE8-B225-F876FF7BA984

The ID of the request.

JobId String 72dcd26b-f12d-4c27-b3af-18f6aed5****

The ID of the asynchronous task.

Examples

Sample requests

http(s)://[Endpoint]/?Action=LoadBalancerJoinSecurityGroup
&SecurityGroupIds=["sg-bp1fg655nh68xyz9****"]
&LoadBalancerId=nlb-83ckzc8d4xlp8o****
&DryRun=true
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&RegionId=cn-hangzhou
&Common request parameters

Sample success responses

XML format

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

<LoadBalancerJoinSecurityGroupResponse>
    <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
    <JobId>72dcd26b-f12d-4c27-b3af-18f6aed5****</JobId>
</LoadBalancerJoinSecurityGroupResponse>

JSON format

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

{
  "RequestId" : "CEF72CEB-54B6-4AE8-B225-F876FF7BA984",
  "JobId" : "72dcd26b-f12d-4c27-b3af-18f6aed5****"
}

Error codes

For a list of error codes, see Service error codes.