Set an instance’s security groups
Sets the complete list of security groups on one instance, by name: groups you list are added, groups you leave out are removed. List instances shows each instance’s current groups.
PUT /v1/instance/security-groups| Field | Type | Required | Description |
|---|---|---|---|
| instanceId | string | yes | The instance’s ID |
| securityGroups | array of strings | yes | The instance’s whole list of group names, 1 to 20, each once |
cURL
curl -X PUT https://api.redu.cloud/v1/instance/security-groups \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"instanceId": "9b8a7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d", "securityGroups": ["default", "db-from-app"]}'Answers once the instance has exactly these groups:
{ "message": "Security groups updated", "security_groups": ["default", "db-from-app"] }An instance always keeps at least one group: with none, it gets no traffic at all.
When an instance gets a public URL, redu opens that port in the groups the instance has at that moment. A group you attach later does not have it: keep a group with the port, or add the rule to the new group first.
Errors
Errors use the API’s standard shape, { "error": { "code", "message", "hint"? } }.
| Status | Code | When |
|---|---|---|
| 400 | validation_error | The list is empty, names a group twice, or the instance ID is malformed |
| 400 | security_group_not_found | One of the names is not a security group in your account |
| 404 | instance_not_found | No such instance in your account |
| 409 | security_group_name_ambiguous | Two of your security groups share one of the names: rename one |
Last updated on