ConfigureSecurityGroupRules

ConfigureSecurityGroupRules

1. API Description

This API is used to configure the rules of a security group.

Note

  • Rules of the default security group cannot be modified.

  • Rules in the same direction cannot be duplicated.

  • A security group has a limited number of rules. If you need more, please contact us.

  • This API is used to configure full rules for the security group.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter Name
Required
Type
Description

securityGroupId

Yes

String

Security group ID.

ruleInfos

Yes

Array of RuleInfo

Security group rules.

3. Output Parameters

Parameter Name
Type
Description

requestId

String

The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Code Example

Configure rules for the security group.

POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: ConfigureSecurityGroupRules
<Common Request Params>

Request:
{
  "securityGroupId": "your-security-group-id",
  "ruleInfos": [
    {
      "direction": "ingress",
      "policy": "accept",
      "priority": 1,
      "ipProtocol": "tcp",
      "portRange": "22",
      "cidrIp": "0.0.0.0/0",
      "desc": "aaa"
    },
    {
      "direction": "egress",
      "policy": "accept",
      "priority": 1,
      "ipProtocol": "tcp",
      "portRange": "22",
      "cidrIp": "0.0.0.0/0",
      "desc": "xxx"
    }
  ]
}

Response:
{
  "requestId": "T58CAD52F-458A-4AFF-8FB5-1EACD453C219",
  "response": {
    "requestId": "T58CAD52F-458A-4AFF-8FB5-1EACD453C219"
  }
}

5. Developer Resources

Zenlayer Cloud API 2.0 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.

HTTP Status Code
Error Code
Description

400

INVALID_PARAMETER_SECURITY_GROUP_RULE_ID_NOT_ALLOW

Security group rule ID is not allowed to be provided.

400

INVALID_PARAMETER_SECURITY_GROUP_POLICY

Invalid security group rule Policy parameter.

400

INVALID_PARAMETER_SECURITY_GROUP_PORT_RANGE

Invalid security group rule PortRange parameter.

400

INVALID_PARAMETER_SECURITY_GROUP_PRIORITY

Invalid security group rule Priority parameter.

400

INVALID_PARAMETER_SECURITY_GROUP_SOURCE_CIDR_IP

Invalid security group rule SourceCidrIp parameter.

403

OPERATION_DENIED_SECURITY_GROUP_EXIST_REPEAT_RULE

Duplicated security group rules.

404

INVALID_SECURITY_GROUP_NOT_FOUND

The specified security group does not exist.

403

OPERATION_DENIED_SECURITY_GROUP_RULE_EXCEED_LIMIT

Quantity of security group rules exceeds the limit.

403

OPERATION_DENIED_DEFAULT_SECURITY_GROUP_NOT_SUPPORT

Not supported for the default security group.

Last updated