Creating a Security Group
Function
A security group is a collection of access control rules for cloud instances, such as cloud servers, containers, and databases, that have the same security requirements and that are mutually trusted within a VPC. You can define different access control rules for a security group, and these rules are then applied to all the instances added to this security group.
Constraints
By default, a security group only allows instances in it to communicate with each other.
Calling Method
For details, see Calling APIs.
URI
POST /v3/{project_id}/vpc/security-groups
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String |
|
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| dry_run | No | Boolean |
|
| security_group | Yes | CreateSecurityGroupOption object |
|
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String |
|
| description | No | String |
|
| tags | No | Array of RequestTag objects |
|
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key | Yes | String | Definition: Tag key. Constraints: N/A. Range:
Default Value: N/A |
| value | Yes | String | Definition: Tag value. Constraints: N/A Range:
Default Value: N/A |
Response Parameters
Status code: 201
| Parameter | Type | Description |
|---|---|---|
| request_id | String |
|
| security_group | SecurityGroupInfo object |
|
| Parameter | Type | Description |
|---|---|---|
| id | String |
|
| name | String |
|
| description | String |
|
| project_id | String |
|
| created_at | String |
|
| updated_at | String |
|
| tags | Array of ResponseTag objects |
|
| security_group_rules | Array of SecurityGroupRule objects |
|
| Parameter | Type | Description |
|---|---|---|
| key | String | Definition: Tag key. Range:
|
| value | String | Definition: Tag value. Range:
|
| Parameter | Type | Description |
|---|---|---|
| id | String |
|
| description | String |
|
| security_group_id | String |
|
| direction | String |
|
| protocol | String |
|
| ethertype | String |
|
| multiport | String |
|
| action | String |
|
| priority | Integer |
|
| remote_group_id | String |
|
| remote_ip_prefix | String |
|
| created_at | String |
|
| updated_at | String |
|
| project_id | String |
|
Status code: 202
| Parameter | Type | Description |
|---|---|---|
| request_id | String |
|
| error_msg | String |
|
| error_code | String |
|
Example Requests
-
Create a security group, set its name to security_group_1 and description to security group description, and specify the request as a prefight request.
POST https://{Endpoint}/v3/{project_id}/vpc/security-groups { "security_group" : { "name" : "security_group_1", "description" : "security group description" }, "dry_run" : true } -
Create a security group and set its name to security_group_1* and description to security group description.
POST https://{Endpoint}/v3/{project_id}/vpc/security-groups { "security_group" : { "name" : "security_group_1", "description" : "security group description" } }
Example Responses
Status code: 201
Normal response to the POST operation. For more status codes, see Status Code.
{
"security_group" : {
"id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325",
"name" : "security_group_1",
"project_id" : "060576782980d5762f9ec014dd2f1148",
"description" : "security group description",
"enterprise_project_id" : "0",
"tags" : [ ],
"security_group_rules" : [ {
"id" : "f11a3824-ac19-4fad-b4f1-c5f4a6dd0a80",
"project_id" : "060576782980d5762f9ec014dd2f1148",
"security_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325",
"remote_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325",
"direction" : "ingress",
"protocol" : null,
"description" : "",
"created_at" : "2020-07-09T05:56:27Z",
"updated_at" : "2020-07-09T05:56:27Z",
"ethertype" : "IPv6",
"remote_ip_prefix" : null,
"multiport" : null,
"remote_address_group_id" : null,
"action" : "allow",
"priority" : 100
}, {
"id" : "3d6480e8-9ea4-46dc-bb1b-8db190cd5677",
"project_id" : "060576782980d5762f9ec014dd2f1148",
"security_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325",
"remote_group_id" : null,
"direction" : "egress",
"protocol" : null,
"description" : "",
"created_at" : "2020-07-09T05:56:27Z",
"updated_at" : "2020-07-09T05:56:27Z",
"ethertype" : "IPv6",
"remote_ip_prefix" : null,
"multiport" : null,
"remote_address_group_id" : null,
"action" : "allow",
"priority" : 100
}, {
"id" : "9581f18c-1fdd-43da-ace9-7758a56ef28a",
"project_id" : "060576782980d5762f9ec014dd2f1148",
"security_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325",
"remote_group_id" : null,
"direction" : "egress",
"protocol" : null,
"description" : "",
"created_at" : "2020-07-09T05:56:27Z",
"updated_at" : "2020-07-09T05:56:27Z",
"ethertype" : "IPv4",
"remote_ip_prefix" : null,
"multiport" : null,
"remote_address_group_id" : null,
"action" : "allow",
"priority" : 100
}, {
"id" : "a3ba270e-e58b-432d-a912-aeb7eace9fb8",
"project_id" : "060576782980d5762f9ec014dd2f1148",
"security_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325",
"remote_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325",
"direction" : "ingress",
"protocol" : null,
"description" : "",
"created_at" : "2020-07-09T05:56:27Z",
"updated_at" : "2020-07-09T05:56:27Z",
"ethertype" : "IPv4",
"remote_ip_prefix" : null,
"multiport" : null,
"remote_address_group_id" : null,
"action" : "allow",
"priority" : 100
} ],
"created_at" : "2020-07-09T05:56:27Z",
"updated_at" : "2020-07-09T05:56:27Z"
},
"request_id" : "a8cf4f79ca3c22ca685e7e8872e8c20b"
} Status code: 202
Normal response for the specified pre-check request of API V3. For more status codes, see Status Code.
{
"error_msg" : "Request validation has been passed with dry run...",
"error_code" : "SYS.0202",
"request_id" : "cfd81aea3f59eac7128dba4b36d516c8"
} Status Codes
| Status Code | Description |
|---|---|
| 201 | Normal response to the POST operation. For more status codes, see Status Code. |
| 202 | Normal response for the specified pre-check request of API V3. For more status codes, see Status Code. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot