Updated on 2026-01-23 GMT+08:00

Creating an Instance

Function

This API is used to create an instance, and pay-per-use and yearly/monthly billing modes are supported.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{engine}/{project_id}/instances

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

engine

Yes

String

Definition

Message engine.

Constraints

N/A

Range

  • rocketmq: RocketMQ message engine.

  • reliability: RocketMQ message engine alias.

Default Value

N/A

project_id

Yes

String

Definition

Project ID. For details about how to obtain it, 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

name

Yes

String

Definition

Instance name.

Constraints

An instance name starts with a letter, consists of 4 to 64 characters, and can contain only letters, digits, underscores (_), and hyphens (-).

Range

N/A

Default Value

N/A

description

No

String

Definition

Description of an instance.

Constraints

0–1024 characters.

The backslash (\) and quotation mark (") are special characters for JSON messages. When using these characters in a parameter value, add the escape character (\) before the characters, for example, *\\* and \".

Range

N/A

Default Value

N/A

engine

Yes

String

Definition

Message engine type.

Constraints

N/A

Range

  • rocketmq: RocketMQ message engine.

  • reliability: RocketMQ message engine alias.

Default Value

N/A

engine_version

Yes

String

Definition

Message engine version.

Constraints

N/A

Range

  • 4.8.0

  • 5.x

Default Value

N/A

storage_space

Yes

Integer

Definition

Storage space, in GB.

Range

Different instance specifications support different storage configurations.

vpc_id

Yes

String

Definition

VPC ID. You can call the API for querying VPCs to obtain the VPC ID. The VPC ID is in the response body. For details, see Virtual Private Cloud API Reference.

Constraints

N/A

Range

N/A

Default Value

N/A

subnet_id

Yes

String

Definition

Subnet information. You can call the API for querying subnets to obtain the subnet ID. The subnet ID is in the response body. For details, see Virtual Private Cloud API Reference.

Constraints

N/A

Range

N/A

Default Value

N/A

security_group_id

Yes

String

Definition

Security group to which the instance belongs. You can call the API for querying security groups to obtain the security group ID. The security group ID is in the response body. For details, see Virtual Private Cloud API Reference.

Constraints

N/A

Range

N/A

Default Value

N/A

available_zones

Yes

Array of strings

Definition

ID of the AZ where instance brokers reside and which has available resources. Obtain the AZ ID by referring to Querying AZ Information.

Constraints

The parameter value cannot be empty or null. Check whether resources exist in the AZs.

A RocketMQ instance can be deployed in 1 AZ or at least 3 AZs. When specifying AZs for brokers, use commas (,) to separate multiple AZs.

Range

N/A

Default Value

N/A

product_id

Yes

String

Definition

RocketMQ instance flavors.

Constraints

N/A

Range

  • c6.4u8g.cluster.small: Max. 2,000 topics and 2,000 consumer groups per broker

  • c6.4u8g.cluster: Max. 4,000 topics and 4,000 consumer groups per broker

  • c6.8u16g.cluster: Max. 8,000 topics and 8,000 consumer groups per broker

  • c6.12u24g.cluster: Max. 12,000 topics and 12,000 consumer groups per broker

  • c6.16u32g.cluster: Max. 16,000 topics and 16,000 consumer groups per broker

  • rocketmq.b1.large.1: RocketMQ 5.x basic edition single-node flavor, instance TPS 500

  • rocketmq.b2.large.4: RocketMQ 5.x basic edition cluster flavor, instance TPS 2,000

  • rocketmq.b2.large.8: RocketMQ 5.x basic edition cluster flavor, instance TPS 4,000

  • rocketmq.b2.large.12: RocketMQ 5.x basic edition cluster flavor, instance TPS 6,000

  • rocketmq.p1.large.1: RocketMQ 5.x professional edition single-node flavor, instance TPS 500

  • rocketmq.p2.large.8: RocketMQ 5.x professional edition cluster flavor, instance TPS 4,000

  • rocketmq.p2.large.12: RocketMQ 5.x professional edition cluster flavor, instance TPS 6,000

  • rocketmq.p2.large.20: RocketMQ 5.x professional edition cluster flavor, instance TPS 10,000

  • rocketmq.p2.large.40: RocketMQ 5.x professional edition cluster flavor, instance TPS 20,000

  • rocketmq.p2.large.100: RocketMQ 5.x professional edition cluster flavor, instance TPS 50,000

  • rocketmq.p2.large.150: RocketMQ 5.x professional edition cluster flavor, instance TPS 75,000

  • rocketmq.p2.large.200: RocketMQ 5.x professional edition cluster flavor, instance TPS 100,000

  • rocketmq.p2.large.300: RocketMQ 5.x professional edition cluster flavor, instance TPS 150,000

Default Value

N/A

ssl_enable

No

Boolean

Definition

Whether to enable SSL-encrypted access.

Constraints

N/A

Range

  • true: Yes

  • false: No

Default Value

false

storage_spec_code

Yes

String

Definition

Storage I/O flavor.

Constraints

N/A

Range

  • dms.physical.storage.high.v2: high I/O disk

  • dms.physical.storage.ultra.v2: ultra-high I/O disk

  • dms.physical.storage.general: general-purpose SSD

  • dms.physical.storage.extreme: extreme SSD

Default Value

N/A

enterprise_project_id

No

String

Definition

Enterprise project ID. This parameter is mandatory for an enterprise project account.

Constraints

N/A

Range

N/A

Default Value

N/A

enable_acl

No

Boolean

Definition

Whether to enable access control.

Constraints

N/A

Range

N/A

Default Value

N/A

ipv6_enable

No

Boolean

Definition

Whether IPv6 is supported.

Constraints

N/A

Range

  • true: Yes

  • false: No

Default Value

false

proxy_enable

No

Boolean

Definition

Whether to enable the proxy function.

Constraints

N/A

Range

  • true: Yes

  • false: No

Default Value

false

enable_publicip

No

Boolean

Definition

Whether to enable public access. By default, public access is disabled.

Constraints

N/A

Range

  • true: Yes

  • false: No

Default Value

false

disk_encrypted_enable

No

Boolean

Definition

Whether to enable disk encryption.

Constraints

N/A

Range

  • true: Yes

  • false: No

Default Value

false

disk_encrypted_key

No

String

Definition

Disk encryption key. The value is blank when disk encryption is disabled.

Constraints

N/A

Range

N/A

Default Value

N/A

publicip_id

No

String

Definition

ID of the EIP bound to the instance.

Constraints

Use commas (,) to separate multiple EIP IDs.

This parameter is mandatory if public access is enabled (that is, enable_publicip is set to true).

Range

N/A

Default Value

N/A

broker_num

Yes

Integer

Definition

Number of brokers.

Constraints

N/A

Range

N/A

Default Value

N/A

arch_type

No

String

Definition

Architecture type.

Constraints

N/A

Range

  • X86: complex instruction set compute.

  • ARM: simplified instruction set compute.

Default Value

N/A

tls_mode

No

String

Definition

Security protocol used by an instance.

Constraints

N/A

Range

N/A

Default Value

N/A

bss_param

No

BssParam object

Definition

Parameter related to the yearly/monthly billing mode. If this parameter is left blank, the billing mode is pay-per-use by default. If this parameter is not left blank, the billing mode is yearly/monthly.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 BssParam

Parameter

Mandatory

Type

Description

is_auto_renew

No

Boolean

Definition

Indicates whether auto-renewal is enabled.

Constraints

N/A

Range

  • true: Subscriptions will be automatically renewed.

  • false: Subscriptions will not be automatically renewed.

Default Value

false

charging_mode

No

String

Definition

Billing mode. This parameter specifies a payment mode.

Constraints

N/A

Range

  • prePaid: indicates the yearly/monthly billing mode.

  • postPaid: pay-per-use billing.

Default Value

postPaid

is_auto_pay

No

Boolean

Definition

Whether the order is automatically or manually paid.

Constraints

N/A

Range

  • true: yes. The order will be automatically paid.

  • false: The order must be manually paid.

Default Value

N/A

period_type

No

String

Definition

Subscription type.

Constraints

This parameter is valid and mandatory only when chargingMode is set to prePaid.

Range

  • month: monthly subscription

  • year: yearly subscription

Default Value

N/A

period_num

No

Integer

Definition

Number of subscription periods.

Constraints

This parameter is valid and mandatory only when chargingMode is set to prePaid.

Range

  • If periodType is month, the value ranges from 1 to 9.

  • If periodType is year, the value ranges from 1 to 3.

Default Value

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

instance_id

String

Definition

Instance ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Example Requests

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

POST https://{endpoint}/v2/reliability/{project_id}/instances

{
  "name" : "reliability-1751840557",
  "description" : "",
  "engine" : "reliability",
  "engine_version" : "4.8.0",
  "storage_space" : 600,
  "vpc_id" : "3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf",
  "subnet_id" : "0a0f1fcb-f019-458d-b9e5-301867394d50",
  "security_group_id" : "23c5977f-ff33-4b95-a73e-08d8a0bc4e6c",
  "available_zones" : [ "9f1c5806706d4c1fb0eb72f0a9b18c77" ],
  "product_id" : "c6.4u8g.cluster",
  "enterprise_project_id" : "0",
  "ssl_enable" : false,
  "storage_spec_code" : "dms.physical.storage.ultra.v2",
  "ipv6_enable" : false,
  "enable_publicip" : false,
  "disk_encrypted_enable" : true,
  "disk_encrypted_key" : "********-b953-4875-a743-************",
  "publicip_id" : "",
  "broker_num" : 1
}

Example Responses

Status code: 200

Instance created successfully.

{
  "instance_id" : "8959ab1c-7n1a-yyb1-a05t-93dfc361b32d"
}

SDK Sample Code

The SDK sample code is as follows.

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

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

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

public class CreateInstanceByEngineSolution {

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

        RocketMQClient client = RocketMQClient.newBuilder()
                .withCredential(auth)
                .withRegion(RocketMQRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateInstanceByEngineRequest request = new CreateInstanceByEngineRequest();
        request.withEngine(CreateInstanceByEngineRequest.EngineEnum.fromValue("{engine}"));
        CreateInstanceByEngineReq body = new CreateInstanceByEngineReq();
        List<String> listbodyAvailableZones = new ArrayList<>();
        listbodyAvailableZones.add("9f1c5806706d4c1fb0eb72f0a9b18c77");
        body.withBrokerNum(1);
        body.withPublicipId("");
        body.withEnablePublicip(false);
        body.withIpv6Enable(false);
        body.withEnterpriseProjectId("0");
        body.withStorageSpecCode(CreateInstanceByEngineReq.StorageSpecCodeEnum.fromValue("dms.physical.storage.ultra.v2"));
        body.withSslEnable(false);
        body.withProductId(CreateInstanceByEngineReq.ProductIdEnum.fromValue("c6.4u8g.cluster"));
        body.withAvailableZones(listbodyAvailableZones);
        body.withSecurityGroupId("23c5977f-ff33-4b95-a73e-08d8a0bc4e6c");
        body.withSubnetId("0a0f1fcb-f019-458d-b9e5-301867394d50");
        body.withVpcId("3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf");
        body.withStorageSpace(600);
        body.withEngineVersion(CreateInstanceByEngineReq.EngineVersionEnum.fromValue("4.8.0"));
        body.withEngine(CreateInstanceByEngineReq.EngineEnum.fromValue("reliability"));
        body.withDescription("");
        body.withName("reliability-1751840557");
        request.withBody(body);
        try {
            CreateInstanceByEngineResponse response = client.createInstanceByEngine(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 pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

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

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkrocketmq.v2.region.rocketmq_region import RocketMQRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkrocketmq.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 = RocketMQClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(RocketMQRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateInstanceByEngineRequest()
        request.engine = "{engine}"
        listAvailableZonesbody = [
            "9f1c5806706d4c1fb0eb72f0a9b18c77"
        ]
        request.body = CreateInstanceByEngineReq(
            broker_num=1,
            publicip_id="",
            enable_publicip=False,
            ipv6_enable=False,
            enterprise_project_id="0",
            storage_spec_code="dms.physical.storage.ultra.v2",
            ssl_enable=False,
            product_id="c6.4u8g.cluster",
            available_zones=listAvailableZonesbody,
            security_group_id="23c5977f-ff33-4b95-a73e-08d8a0bc4e6c",
            subnet_id="0a0f1fcb-f019-458d-b9e5-301867394d50",
            vpc_id="3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf",
            storage_space=600,
            engine_version="4.8.0",
            engine="reliability",
            description="",
            name="reliability-1751840557"
        )
        response = client.create_instance_by_engine(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 pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

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

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    rocketmq "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/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 := rocketmq.NewRocketMQClient(
        rocketmq.RocketMQClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.CreateInstanceByEngineRequest{}
	request.Engine = model.GetCreateInstanceByEngineRequestEngineEnum().ENGINE
	var listAvailableZonesbody = []string{
        "9f1c5806706d4c1fb0eb72f0a9b18c77",
    }
	publicipIdCreateInstanceByEngineReq:= ""
	enablePublicipCreateInstanceByEngineReq:= false
	ipv6EnableCreateInstanceByEngineReq:= false
	enterpriseProjectIdCreateInstanceByEngineReq:= "0"
	sslEnableCreateInstanceByEngineReq:= false
	descriptionCreateInstanceByEngineReq:= ""
	request.Body = &model.CreateInstanceByEngineReq{
		BrokerNum: int32(1),
		PublicipId: &publicipIdCreateInstanceByEngineReq,
		EnablePublicip: &enablePublicipCreateInstanceByEngineReq,
		Ipv6Enable: &ipv6EnableCreateInstanceByEngineReq,
		EnterpriseProjectId: &enterpriseProjectIdCreateInstanceByEngineReq,
		StorageSpecCode: model.GetCreateInstanceByEngineReqStorageSpecCodeEnum().DMS_PHYSICAL_STORAGE_ULTRA,
		SslEnable: &sslEnableCreateInstanceByEngineReq,
		ProductId: model.GetCreateInstanceByEngineReqProductIdEnum().C6_4U8G_CLUSTER,
		AvailableZones: listAvailableZonesbody,
		SecurityGroupId: "23c5977f-ff33-4b95-a73e-08d8a0bc4e6c",
		SubnetId: "0a0f1fcb-f019-458d-b9e5-301867394d50",
		VpcId: "3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf",
		StorageSpace: int32(600),
		EngineVersion: model.GetCreateInstanceByEngineReqEngineVersionEnum().E_4_8_0,
		Engine: model.GetCreateInstanceByEngineReqEngineEnum().RELIABILITY,
		Description: &descriptionCreateInstanceByEngineReq,
		Name: "reliability-1751840557",
	}
	response, err := client.CreateInstanceByEngine(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

Instance created successfully.

Error Codes

See Error Codes.