Updated on 2026-06-22 GMT+08:00

Creating a Cluster (V2)

Function

This API is used to create a cluster.

The cluster must run in a VPC. Before creating a cluster, you need to create a VPC and obtain the VPC and subnet IDs.

This API is an asynchronous API. It takes 10 to 15 minutes to create a cluster.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/clusters

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. To obtain the value, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

cluster

No

V2CreateCluster object

Definition

Request body for creating a cluster (V2).

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 V2CreateCluster

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

Cluster name, which must be unique.

Constraints

N/A

Range

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

Default Value

N/A

flavor

Yes

String

Definition

Cluster flavor code.

Constraints

N/A

Range

See the flavor code returned by the API for querying flavor.

Default Value

N/A

num_cn

No

Integer

Definition

Number of CNs in a cluster.

Constraints

N/A

Range

2 to The number of cluster nodes. Maximum value: 20. Default value: 3.

Default Value

N/A

num_node

Yes

Integer

Definition

Number of nodes in a cluster.

Constraints

N/A

Range

For a cluster, the value is from 3 to 256. For a hybrid data warehouse (standalone), the value is 1.

Default Value

N/A

db_name

Yes

String

Definition

Administrator username.

Constraints

N/A

Range

Contain only lowercase letters, digits, and underscores (). Must start with a lowercase letter or an underscore ().

Contain 1 to 63 characters.

Cannot be a keyword of the GaussDB(DWS) database.

Default Value

N/A

db_password

Yes

String

Definition

Password of the administrator.

Constraints

N/A

Range

12 to 32 characters.

At least three types of the following characters: uppercase letters, lowercase letters, digits, and special characters (~!?, .:;-_(){}[]/<>@# %^&*+|=).

Cannot be the username or the username spelled backwards.

Default Value

N/A

db_port

Yes

Integer

Definition

Cluster database port.

Constraints

N/A

Range

8000 to 30000

Default Value

8000

dss_pool_id

No

String

Definition

Dedicated storage pool ID. Generally, you do not need to specify this parameter.

Constraints

N/A

Range

N/A

Default Value

null

availability_zones

Yes

Array of strings

Definition

AZ information. When creating a 3-AZ cluster, you need to enter three different AZs.

Constraints

N/A

Range

To obtain the value, see Querying AZs.

Default Value

N/A

tags

No

Array of Tags objects

Definition

Tag information.

Constraints

N/A

Range

N/A

Default Value

N/A

vpc_id

Yes

String

Definition

VPC ID, which is used for configuring cluster network.

Constraints

N/A

Range

N/A

Default Value

N/A

subnet_id

Yes

String

Definition

Subnet ID, which is used for configuring the cluster network.

Constraints

N/A

Range

N/A

Default Value

N/A

security_group_id

No

String

Definition

Security group ID, which is used for configuring the cluster network.

Constraints

N/A

Range

N/A

Default Value

N/A

public_ip

No

PublicIp object

Definition

Public IP address. If the parameter is not specified, public connection is not used by default.

Constraints

N/A

Range

N/A

Default Value

N/A

datastore_version

Yes

String

Definition

Cluster version.

Constraints

N/A

Range

N/A

Default Value

N/A

master_key_id

No

String

Definition

KMS key ID.

Constraints

N/A

Range

N/A

Default Value

N/A

master_key_name

No

String

Definition

KMS key name.

Constraints

N/A

Range

N/A

Default Value

N/A

crypt_algorithm

No

String

Definition

KMS encryption algorithm.

Constraints

N/A

Range

N/A

Default Value

N/A

volume

Yes

Volume object

Definition

Disk information.

Constraints

N/A

Range

N/A

Default Value

N/A

enterprise_project_id

No

String

Definition

Enterprise project ID for a cluster. If this parameter is not specified, the default value 0 (indicating that the ID of the default enterprise project) is used.

Constraints

N/A

Range

N/A

Default Value

0

ipv6_enable

No

Boolean

Definition

Network protocol type. It indicates whether IPv6 is supported. By default, IPv6 is not used. If IPv6 is used, the selected subnet must support IPv6.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 Tags

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

Tag key.

Constraints

N/A

Range

  • It can contain a maximum of 128 Unicode characters. It cannot be an empty string, and cannot start or end with a space.

  • It cannot contain the following characters: =*<>\,|/

  • Only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-) are allowed.

Default Value

N/A

value

Yes

String

Definition

Tag value.

Constraints

N/A

Range

  • The value can contain a maximum of 256 characters and can be an empty string. It cannot start or end with a space.

  • It cannot contain the following characters: =*<>\,|/

  • Only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-) are allowed.

Default Value

N/A

Table 5 PublicIp

Parameter

Mandatory

Type

Description

public_bind_type

No

String

Definition

EIP binding type.

Constraints

N/A

Range

auto_assign

not_use

bind_existing

Default Value

null

eip_id

No

String

Definition

EIP ID.

Constraints

N/A

Range

N/A

Default Value

null

Table 6 Volume

Parameter

Mandatory

Type

Description

volume

Yes

String

Definition

Disk name.

Constraints

N/A

Range

  • SSD: Ultra-high I/O

  • SAS: High I/O

  • SATA: Common I/O

Default Value

N/A

capacity

No

Integer

Definition

Disk capacity in GB.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

cluster

Cluster object

Definition

Cluster object.

Range

N/A

Table 8 Cluster

Parameter

Type

Description

id

String

Definition

Cluster ID.

Range

N/A

Example Requests

Create a multi-AZ DWS cluster (Cluster version: 8.2.1. AZs: az1 and az2. Node flavor: dws.m1.xlarge.ultrahigh. Nodes: 3. Disk type: SSD disk with 100 GB capacity. Database port: 8000. Public IP address, security Group ID, Subnet ID, VPC ID are configured).

POST https://{Endpoint}/v2/89cd04f168b84af6be287f71730fdb4b/clusters

{
  "cluster" : {
    "flavor" : "dws.m1.xlarge.ultrahigh",
    "num_node" : 3,
    "subnet_id" : "374eca02-cfc4-4de7-8ab5-dbebf7d9a720",
    "security_group_id" : "dc3ec145-9029-4b39-b5a3-ace5a01f772b",
    "vpc_id" : "85b20d7e-9eb7-4b2a-98f3-3c8843ea3574",
    "db_port" : 8000,
    "datastore_version" : "8.2.1",
    "availability_zones" : [ "az1", "az2" ],
    "name" : "dws-1",
    "num_cn" : 3,
    "db_name" : "dbadmin",
    "db_password" : "Passw0rd!",
    "public_ip" : {
      "public_bind_type" : "auto_assign",
      "eip_id" : ""
    },
    "volume" : {
      "volume" : "SSD",
      "capacity" : 100
    },
    "enterprise_project_id" : "aca4e50a-266f-4786-827c-f8d6cc3fbada"
  }
}

Example Responses

Status code: 200

The request for creating a cluster is submitted.

{
  "cluster" : {
    "id" : "7d85f602-a948-4a30-afd4-e84f47471c15"
  }
}

SDK Sample Code

The SDK sample code is as follows.

Create a multi-AZ DWS cluster (Cluster version: 8.2.1. AZs: az1 and az2. Node flavor: dws.m1.xlarge.ultrahigh. Nodes: 3. Disk type: SSD disk with 100 GB capacity. Database port: 8000. Public IP address, security Group ID, Subnet ID, VPC ID are configured).

 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
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.dws.v2.region.DwsRegion;
import com.huaweicloud.sdk.dws.v2.*;
import com.huaweicloud.sdk.dws.v2.model.*;

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

public class CreateClusterV2Solution {

    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);

        DwsClient client = DwsClient.newBuilder()
                .withCredential(auth)
                .withRegion(DwsRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateClusterV2Request request = new CreateClusterV2Request();
        V2CreateClusterReq body = new V2CreateClusterReq();
        Volume volumeCluster = new Volume();
        volumeCluster.withVolume("SSD")
            .withCapacity(100);
        PublicIp publicIpCluster = new PublicIp();
        publicIpCluster.withPublicBindType("auto_assign")
            .withEipId("");
        List<String> listClusterAvailabilityZones = new ArrayList<>();
        listClusterAvailabilityZones.add("az1");
        listClusterAvailabilityZones.add("az2");
        V2CreateCluster clusterbody = new V2CreateCluster();
        clusterbody.withName("dws-1")
            .withFlavor("dws.m1.xlarge.ultrahigh")
            .withNumCn(3)
            .withNumNode(3)
            .withDbName("dbadmin")
            .withDbPassword("Passw0rd!")
            .withDbPort(8000)
            .withAvailabilityZones(listClusterAvailabilityZones)
            .withVpcId("85b20d7e-9eb7-4b2a-98f3-3c8843ea3574")
            .withSubnetId("374eca02-cfc4-4de7-8ab5-dbebf7d9a720")
            .withSecurityGroupId("dc3ec145-9029-4b39-b5a3-ace5a01f772b")
            .withPublicIp(publicIpCluster)
            .withDatastoreVersion("8.2.1")
            .withVolume(volumeCluster)
            .withEnterpriseProjectId("aca4e50a-266f-4786-827c-f8d6cc3fbada");
        body.withCluster(clusterbody);
        request.withBody(body);
        try {
            CreateClusterV2Response response = client.createClusterV2(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());
        }
    }
}

Create a multi-AZ DWS cluster (Cluster version: 8.2.1. AZs: az1 and az2. Node flavor: dws.m1.xlarge.ultrahigh. Nodes: 3. Disk type: SSD disk with 100 GB capacity. Database port: 8000. Public IP address, security Group ID, Subnet ID, VPC ID are configured).

 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdws.v2.region.dws_region import DwsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdws.v2 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 = DwsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DwsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateClusterV2Request()
        volumeCluster = Volume(
            volume="SSD",
            capacity=100
        )
        publicIpCluster = PublicIp(
            public_bind_type="auto_assign",
            eip_id=""
        )
        listAvailabilityZonesCluster = [
            "az1",
            "az2"
        ]
        clusterbody = V2CreateCluster(
            name="dws-1",
            flavor="dws.m1.xlarge.ultrahigh",
            num_cn=3,
            num_node=3,
            db_name="dbadmin",
            db_password="Passw0rd!",
            db_port=8000,
            availability_zones=listAvailabilityZonesCluster,
            vpc_id="85b20d7e-9eb7-4b2a-98f3-3c8843ea3574",
            subnet_id="374eca02-cfc4-4de7-8ab5-dbebf7d9a720",
            security_group_id="dc3ec145-9029-4b39-b5a3-ace5a01f772b",
            public_ip=publicIpCluster,
            datastore_version="8.2.1",
            volume=volumeCluster,
            enterprise_project_id="aca4e50a-266f-4786-827c-f8d6cc3fbada"
        )
        request.body = V2CreateClusterReq(
            cluster=clusterbody
        )
        response = client.create_cluster_v2(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Create a multi-AZ DWS cluster (Cluster version: 8.2.1. AZs: az1 and az2. Node flavor: dws.m1.xlarge.ultrahigh. Nodes: 3. Disk type: SSD disk with 100 GB capacity. Database port: 8000. Public IP address, security Group ID, Subnet ID, VPC ID are configured).

 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/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 := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := dws.NewDwsClient(
        dws.DwsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.CreateClusterV2Request{}
	capacityVolume:= int32(100)
	volumeCluster := &model.Volume{
		Volume: "SSD",
		Capacity: &capacityVolume,
	}
	publicBindTypePublicIp:= "auto_assign"
	eipIdPublicIp:= ""
	publicIpCluster := &model.PublicIp{
		PublicBindType: &publicBindTypePublicIp,
		EipId: &eipIdPublicIp,
	}
	var listAvailabilityZonesCluster = []string{
        "az1",
	    "az2",
    }
	numCnCluster:= int32(3)
	securityGroupIdCluster:= "dc3ec145-9029-4b39-b5a3-ace5a01f772b"
	enterpriseProjectIdCluster:= "aca4e50a-266f-4786-827c-f8d6cc3fbada"
	clusterbody := &model.V2CreateCluster{
		Name: "dws-1",
		Flavor: "dws.m1.xlarge.ultrahigh",
		NumCn: &numCnCluster,
		NumNode: int32(3),
		DbName: "dbadmin",
		DbPassword: "Passw0rd!",
		DbPort: int32(8000),
		AvailabilityZones: listAvailabilityZonesCluster,
		VpcId: "85b20d7e-9eb7-4b2a-98f3-3c8843ea3574",
		SubnetId: "374eca02-cfc4-4de7-8ab5-dbebf7d9a720",
		SecurityGroupId: &securityGroupIdCluster,
		PublicIp: publicIpCluster,
		DatastoreVersion: "8.2.1",
		Volume: volumeCluster,
		EnterpriseProjectId: &enterpriseProjectIdCluster,
	}
	request.Body = &model.V2CreateClusterReq{
		Cluster: clusterbody,
	}
	response, err := client.CreateClusterV2(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

200

The request for creating a cluster is submitted.

400

Request error.

401

Authentication failed.

403

You do not have required permissions.

500

Internal server error.

503

Service unavailable.