CreateSecurityGroup

CreateSecurityGroup

1. API Description

This API is used to create a security group.

Note

  • A single team can create a limited number of security groups. If you need more, please contact us.

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

  • Rules in the same direction cannot be duplicated.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter Name
Required
Type
Description

scope

No

String

Deployment scope. Only Global is supported currently.

Default value: Global.

securityGroupName

Yes

String

Security group name.

The length is 1 to 64 characters. Only letters, numbers, - and periods (.) are supported.

ruleInfos

No

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.

securityGroupId

String

The security group ID.

4. Code Example

Create a security group.

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

Request:
{
  "securityGroupName": "test123",
  "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": "TA851AB85-577F-41BE-8E76-68171F021E36",
  "response": {
    "requestId": "TA851AB85-577F-41BE-8E76-68171F021E36",
    "securityGroupId": "your-security-group-id"
  }
}

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_CIDR_IP

Invalid source IP address range.

400

INVALID_PARAMETER_SECURITY_GROUP_DESC

The rule description contains invalid characters.

400

INVALID_PARAMETER_SECURITY_GROUP_DIRECTION

Inbound or outbound rules error.

400

INVALID_PARAMETER_SECURITY_GROUP_IP_PROTOCOL

Invalid IP protocol.

400

INVALID_PARAMETER_SECURITY_GROUP_PORT_RANGE

Invalid port range.

400

INVALID_PARAMETER_SECURITY_GROUP_PRIORITY

Invalid priority range.

403

OPERATION_DENIED_SECURITY_GROUP_TEAM_EXCEED_LIMIT

The number of security groups exceeds the quota limit.

Last updated