Create Security Group
POST
/v2.0/security-groupsCreates an empty security group. A new group has no rules, so it denies all ingress and allows all egress until you add rules.
info
Source: create-security-group
Request
Parameters
security_groupobjectrequiredSecurity group wrapper.
5 fields
namestringrequiredbodyGroup name. Names are not unique; the ID is the identifier.
descriptionstringbodyFree-form description.
statefulbooleanbodyDefault true. Stateful means return traffic for an allowed connection is permitted automatically. Leave it true unless the deployment supports stateless groups.
tenant_idstringbodyProject ID. Only an administrator can create a group in another project.
tagsarraybodyTags to attach to the group.
Sample Request
curl -ks -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
-d '{
"security_group": {
"name": "web-sg",
"description": "HTTP and HTTPS from anywhere"
}
}' https://api.vietnix.cloud:9696/v2.0/security-groups
Response
Sample Response
Response body
{
"security_group": {
"id": "b7e4d2c1-8f3a-4b6d-9c05-1e2f3a4b5c60",
"name": "web-sg",
"description": "HTTP and HTTPS from anywhere",
"stateful": true,
"tenant_id": "f5d834d636c642c7bfe8af86139c6f26",
"project_id": "f5d834d636c642c7bfe8af86139c6f26",
"security_group_rules": [],
"tags": []
}
}
Status Code
Success
| Status Code | Description |
|---|---|
| 201 - Created | The security group was created. |
Error
| Status Code | Description |
|---|---|
| 400 - Bad Request | The name is missing or the body is malformed. |
| 401 - Unauthorized | User must authenticate before making a request. |
| 403 - Forbidden | Policy does not allow current user to do this operation. |
| 409 - Conflict | A group with the same name and project already exists. |
note
To use the group, add rules (see Manage Security Group Rules) and then attach it to a port or pass its name in networks.security_groups when creating a VM (see Create VM). A group with no rules blocks all inbound traffic.