Updated on 2026-09-18 GMT+08:00

Creating a Cluster

Function

This API is used to create a cluster.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, no identity policy-based permission required for calling this API.

URI

POST /v1.1/{project_id}/clusters

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain it, see Project ID and Account ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. This parameter is mandatory when Token Authentication is used. You can obtain it from the X-Subject-Token header in the response of the "Obtaining a User Token" API provided by IAM.

X-Language

Yes

String

Request language

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

cluster

Yes

cluster object

Cluster properties.

auto_remind

No

Boolean

Whether to enable message notifications. After this function is enabled, you can configure up to 20 mobile numbers or email addresses. When a job (currently only table/file migration jobs) fails or an EIP exception occurs, SMS or email notifications will be sent.

phone_num

No

String

Mobile number for receiving notifications

email

No

String

Email address for receiving notifications

Table 4 cluster

Parameter

Mandatory

Type

Description

scheduleBootTime

No

String

Scheduled start time. The CDM cluster is started at this time every day. For example, 00:00:00 indicates that the cluster is started at 00:00 every day.

isScheduleBootOff

No

Boolean

Whether to enable scheduled startup/shutdown. The scheduled startup/shutdown and auto shutdown functions cannot be enabled at the same time.

instances

No

Array of instance objects

Node list.

datastore

No

Datastore object

Cluster version information.

extended_properties

No

ExtendedProperties object

Extended properties.

scheduleOffTime

No

String

Scheduled shutdown time. When the scheduled shutdown is triggered, the system does not wait for incomplete jobs to complete. For example, 10:00:00 indicates that the cluster is shut down at 10:00 every day.

vpcId

Yes

String

VPC ID, which is used for configuring a network for the cluster.

name

Yes

String

Cluster name. The value must start with a letter and contain 4 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.

sys_tags

No

Array of sys_tags objects

Enterprise project information.

isAutoOff

No

Boolean

Whether to enable auto shutdown. The auto shutdown and scheduled startup/shutdown functions cannot be enabled at the same time. After auto shutdown is enabled, if no job is running in the cluster and no scheduled job is created, a cluster will automatically shut down 15 minutes later to reduce costs.

Table 5 instance

Parameter

Mandatory

Type

Description

availability_zone

Yes

String

AZ where the cluster is located. For details about how to obtain the value, see Querying All AZs.

nics

Yes

Array of nics objects

NIC list. A maximum of two NICs are supported.

flavorRef

Yes

String

Instance flavor.

  • a79fd5ae-1833-448a-88e8-3ea2b913e1f6: cdm.small with 2 vCPUs and 4 GB memory applicable to Proof of Concept (PoC) verification and development tests

  • fb8fe666-6734-4b11-bc6c-43d11db3c745: cdm.medium with 4 vCPUs and 8 GB memory applicable to the migration of a single database table with fewer than 10 million pieces of data

  • 5ddb1071-c5d7-40e0-a874-8a032e81a697: cdm.large with 8 vCPUs and 16 GB memory applicable to the migration of a single database table with 10 million pieces of data or more

  • 6ddb1072-c5d7-40e0-a874-8a032e81a698: cdm.xlarge with 16 vCPUs and 32 GB memory applicable to TB-level data migration requiring 10GE high-speed bandwidth

type

Yes

String

Node type. Currently, only cdm is available.

Table 6 nics

Parameter

Mandatory

Type

Description

securityGroupId

Yes

String

Security group ID

net-id

Yes

String

Subnet ID

Table 7 Datastore

Parameter

Mandatory

Type

Description

type

No

String

Type. Generally, the value is cdm.

version

No

String

Cluster version. For example, 2.9.3.300.

Table 8 ExtendedProperties

Parameter

Mandatory

Type

Description

workSpaceId

No

String

Workspace ID

resourceId

No

String

Resource ID

trial

No

String

Whether the cluster is a trial cluster. Options:

  • true: Trial cluster.

  • false: Not a trial cluster.

Table 9 sys_tags

Parameter

Mandatory

Type

Description

value

Yes

String

Enterprise project ID

key

Yes

String

The value is fixed at _sys_enterprise_project_id.

Response Parameters

Status code: 202

Table 10 Response body parameters

Parameter

Type

Description

name

String

Cluster name

id

String

Cluster ID

task

Task object

Task information

datastore

Datastore object

Cluster version information.

instances

Array of ClusterInstance objects

Cluster node information

Table 11 Task

Parameter

Type

Description

id

String

Task ID.

name

String

Task name

Table 12 Datastore

Parameter

Type

Description

type

String

Type. Generally, the value is cdm.

version

String

Cluster version. For example, 2.9.3.300.

Table 13 ClusterInstance

Parameter

Type

Description

id

String

Node VM ID

name

String

Name of the VM on the node

type

String

Node type. Currently, only cdm is available.

shard_id

String

Shard ID

Example Requests

Creating a CDM cluster whose version is 1.8.10 and name is cdm-ab82

POST /v1.1/1551c7f6c808414d8e9f3c514a170f2e/clusters

{
  "cluster" : {
    "scheduleBootTime" : "",
    "isScheduleBootOff" : false,
    "instances" : [ {
      "availability_zone" : "xx-xxx",
      "nics" : [ {
        "securityGroupId" : "c37852d2-2d12-41cb-af47-65c80e995c80",
        "net-id" : "2d120298-6130-44d4-a438-454912fff901"
      } ],
      "flavorRef" : "5ddb1071-c5d7-40e0-a874-8a032e81a697",
      "type" : "cdm"
    } ],
    "datastore" : {
      "type" : "cdm",
      "version" : "1.8.10"
    },
    "scheduleOffTime" : "",
    "vpcId" : "67c06084-2212-4242-bcd4-d2144c2385a9",
    "name" : "cdm-ab82",
    "sys_tags" : [ {
      "value" : "1ce45885-4033-40d2-bdde-d4dbaceb387d",
      "key" : "_sys_enterprise_project_id"
    } ],
    "isAutoOff" : false
  },
  "auto_remind" : false,
  "phone_num" : "",
  "email" : ""
}

Example Responses

Status code: 202

Accepted.

{
  "id" : "befc862c-9286-46a0-a1d6-300d98b63aad",
  "name" : "cdm-4ef213",
  "task" : {
    "id" : "2c9080047f1b1185017f1ef6ad0500ac",
    "name" : "rdsCreateBackupJob"
  },
  "datastore" : {
    "type" : "cdm",
    "version" : "2.9.1.100"
  },
  "instances" : [ {
    "id" : "b2672e7d-2faf-423f-96bb-0664cd743cfd",
    "name" : "cdm-4ef213-cdm-dn-1-1",
    "type" : "cdm",
    "shard_id" : "dn-1"
  } ]
}

SDK Sample Code

The SDK sample code is as follows.

Creating a CDM cluster whose version is 1.8.10 and name is cdm-ab82

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.cdm.v1.region.CdmRegion;
import com.huaweicloud.sdk.cdm.v1.*;
import com.huaweicloud.sdk.cdm.v1.model.*;

import java.util.List;
import java.util.ArrayList;

public class CreateClusterSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        CdmClient client = CdmClient.newBuilder()
                .withCredential(auth)
                .withRegion(CdmRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateClusterRequest request = new CreateClusterRequest();
        CdmCreateClusterReq body = new CdmCreateClusterReq();
        List<SysTags> listClusterSysTags = new ArrayList<>();
        listClusterSysTags.add(
            new SysTags()
                .withValue("1ce45885-4033-40d2-bdde-d4dbaceb387d")
                .withKey("_sys_enterprise_project_id")
        );
        Datastore datastoreCluster = new Datastore();
        datastoreCluster.withType("cdm")
            .withVersion("1.8.10");
        List<Nics> listInstancesNics = new ArrayList<>();
        listInstancesNics.add(
            new Nics()
                .withSecurityGroupId("c37852d2-2d12-41cb-af47-65c80e995c80")
                .withNetId("2d120298-6130-44d4-a438-454912fff901")
        );
        List<Instance> listClusterInstances = new ArrayList<>();
        listClusterInstances.add(
            new Instance()
                .withAvailabilityZone("xx-xxx")
                .withNics(listInstancesNics)
                .withFlavorRef("5ddb1071-c5d7-40e0-a874-8a032e81a697")
                .withType("cdm")
        );
        CdmCreateClusterReqCluster clusterbody = new CdmCreateClusterReqCluster();
        clusterbody.withScheduleBootTime("")
            .withIsScheduleBootOff(false)
            .withInstances(listClusterInstances)
            .withDatastore(datastoreCluster)
            .withScheduleOffTime("")
            .withVpcId("67c06084-2212-4242-bcd4-d2144c2385a9")
            .withName("cdm-ab82")
            .withSysTags(listClusterSysTags)
            .withIsAutoOff(false);
        body.withEmail("");
        body.withPhoneNum("");
        body.withAutoRemind(false);
        body.withCluster(clusterbody);
        request.withBody(body);
        try {
            CreateClusterResponse response = client.createCluster(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Creating a CDM cluster whose version is 1.8.10 and name is cdm-ab82

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcdm.v1.region.cdm_region import CdmRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcdm.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = CdmClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CdmRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateClusterRequest()
        listSysTagsCluster = [
            SysTags(
                value="1ce45885-4033-40d2-bdde-d4dbaceb387d",
                key="_sys_enterprise_project_id"
            )
        ]
        datastoreCluster = Datastore(
            type="cdm",
            version="1.8.10"
        )
        listNicsInstances = [
            Nics(
                security_group_id="c37852d2-2d12-41cb-af47-65c80e995c80",
                net_id="2d120298-6130-44d4-a438-454912fff901"
            )
        ]
        listInstancesCluster = [
            Instance(
                availability_zone="xx-xxx",
                nics=listNicsInstances,
                flavor_ref="5ddb1071-c5d7-40e0-a874-8a032e81a697",
                type="cdm"
            )
        ]
        clusterbody = CdmCreateClusterReqCluster(
            schedule_boot_time="",
            is_schedule_boot_off=False,
            instances=listInstancesCluster,
            datastore=datastoreCluster,
            schedule_off_time="",
            vpc_id="67c06084-2212-4242-bcd4-d2144c2385a9",
            name="cdm-ab82",
            sys_tags=listSysTagsCluster,
            is_auto_off=False
        )
        request.body = CdmCreateClusterReq(
            email="",
            phone_num="",
            auto_remind=False,
            cluster=clusterbody
        )
        response = client.create_cluster(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Creating a CDM cluster whose version is 1.8.10 and name is cdm-ab82

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    cdm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := cdm.CdmClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := cdm.NewCdmClient(hcClient)

    request := &model.CreateClusterRequest{}
	var listSysTagsCluster = []model.SysTags{
        {
            Value: "1ce45885-4033-40d2-bdde-d4dbaceb387d",
            Key: "_sys_enterprise_project_id",
        },
    }
	typeDatastore:= "cdm"
	versionDatastore:= "1.8.10"
	datastoreCluster := &model.Datastore{
		Type: &typeDatastore,
		Version: &versionDatastore,
	}
	var listNicsInstances = []model.Nics{
        {
            SecurityGroupId: "c37852d2-2d12-41cb-af47-65c80e995c80",
            NetId: "2d120298-6130-44d4-a438-454912fff901",
        },
    }
	var listInstancesCluster = []model.Instance{
        {
            AvailabilityZone: "xx-xxx",
            Nics: listNicsInstances,
            FlavorRef: "5ddb1071-c5d7-40e0-a874-8a032e81a697",
            Type: "cdm",
        },
    }
	scheduleBootTimeCluster:= ""
	isScheduleBootOffCluster:= false
	scheduleOffTimeCluster:= ""
	isAutoOffCluster:= false
	clusterbody := &model.CdmCreateClusterReqCluster{
		ScheduleBootTime: &scheduleBootTimeCluster,
		IsScheduleBootOff: &isScheduleBootOffCluster,
		Instances: &listInstancesCluster,
		Datastore: datastoreCluster,
		ScheduleOffTime: &scheduleOffTimeCluster,
		VpcId: "67c06084-2212-4242-bcd4-d2144c2385a9",
		Name: "cdm-ab82",
		SysTags: &listSysTagsCluster,
		IsAutoOff: &isAutoOffCluster,
	}
	emailCdmCreateClusterReq:= ""
	phoneNumCdmCreateClusterReq:= ""
	autoRemindCdmCreateClusterReq:= false
	request.Body = &model.CdmCreateClusterReq{
		Email: &emailCdmCreateClusterReq,
		PhoneNum: &phoneNumCdmCreateClusterReq,
		AutoRemind: &autoRemindCdmCreateClusterReq,
		Cluster: clusterbody,
	}
	response, err := client.CreateCluster(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

202

Accepted.

400

Request error.

401

Authorization failed.

403

No operation permissions.

404

No resources found.

500

Internal interface error.

503

Service unavailable.

Error Codes

See Error Codes.