Updated on 2025-12-10 GMT+08:00

Creating an ECS Group

Function

This API is used to create an ECS group.

Constraints

Only anti-affinity groups are supported.

Debugging

You can debug this API in API Explorer.

Authorization

Each account has all of the permissions required to call all APIs, but IAM users must have the required permissions specifically assigned.
  • If you are using role/policy-based authorization, see the required permissions in Permissions and Supported Actions.
  • If you are using identity policy-based authorization, the permissions listed below are required.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

ecs:cloudServers:createServerGroup

write

-

-

ecs:cloudServers:create

-

URI

POST /v1/{project_id}/cloudservers/os-server-groups

Table 1 describes the parameters in the URI.
Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

For details about how to obtain the ID, see Obtaining a Project ID.

Request

Table 2 describes the request parameters.

Table 2 Request parameters

Parameter

Mandatory

Type

Description

server_group

Yes

Object

Definition

Specifies the ECS group information. For details, see Table 3.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 server_group parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

Specifies the ECS group name.

Constraints

N/A

Range

1 to 255 characters

Default Value

N/A

policies

Yes

Array of strings

Definition

Specifies the list of policies associated with the ECS group.

Constraints

N/A

Range

  • anti-affinity: ECSs in this group must be deployed on different hosts.

Default Value

N/A

Response

Table 4 describes the response parameters.

Table 4 Response parameters

Parameter

Type

Description

server_group

Object

Definition

Specifies the ECS group information. For details, see Table 5.

Range

N/A

Table 5 server_group parameters

Parameter

Type

Description

id

String

Definition

Specifies the ECS group UUID.

Range

N/A

name

String

Definition

Specifies the ECS group name.

Range

N/A

policies

Array of strings

Definition

Specifies the list of policies associated with the ECS group.

Range

  • anti-affinity: ECSs in this group must be deployed on different hosts.

members

Array of strings

Definition

Specifies the IDs of the ECSs in an ECS group.

Range

N/A

metadata

Object

Definition

Specifies the ECS group metadata.

Range

N/A

Example Request

Create an ECS group.

POST https://{endpoint}/v1/{project_id}/cloudservers/os-server-groups

{
    "server_group": {
        "name": "test",
        "policies": ["anti-affinity"]
    }
}

Example Response

{
    "server_group": {
        "id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
        "name": "test",
        "policies": [
            "anti-affinity"
        ],
        "members": [],
        "metadata": {}
    }
}

Error Codes

See Error Codes.