tencent cloud

Feedback

CreateDBInstance

Last updated: 2023-03-20 10:55:17

1. API Description

Domain name for API request: mongodb.tencentcloudapi.com.

This API is used to create a monthly subscription TencentDB for MongoDB instance. The purchasable specifications supported by this API can be obtained through the DescribeSpecInfo API.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateDBInstance.
Version Yes String Common Params. The value used for this API: 2019-07-25.
Region No String Common Params. This parameter is not required for this API.
NodeNum Yes Integer The number of nodes in each replica set. The value range is subject to the response parameter of the DescribeSpecInfo API.
Memory Yes Integer Instance memory size in GB.
Volume Yes Integer Instance disk size in GB.
MongoVersion Yes String Version number. For the specific purchasable versions supported, please see the return result of the DescribeSpecInfo API. The correspondences between parameters and versions are as follows: MONGO_3_WT: MongoDB 3.2 WiredTiger Edition; MONGO_3_ROCKS: MongoDB 3.2 RocksDB Edition; MONGO_36_WT: MongoDB 3.6 WiredTiger Edition; MONGO_40_WT: MongoDB 4.0 WiredTiger Edition; MONGO_42_WT: MongoDB 4.2 WiredTiger Edition.
GoodsNum Yes Integer Number of instances. Minimum value: 1. Maximum value: 10.
Zone Yes String AZ in the format of ap-guangzhou-2. If multi-AZ deployment is enabled, this parameter refers to the primary AZ and must be one of the values of AvailabilityZoneList.
Period Yes Integer Instance validity period in months. Valid values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36.
MachineCode Yes String Server type. Valid values: HIO (high IO), HIO10G (10-gigabit high IO), STDS5 (standard).
ClusterType Yes String Instance type. Valid values: REPLSET (replica set), SHARD (sharded cluster), STANDALONE (single-node).
ReplicateSetNum Yes Integer Number of replica sets. To create a replica set instance, set this parameter to 1; to create a shard instance, see the parameters returned by the DescribeSpecInfo API; to create a single-node instance, set this parameter to 0.
ProjectId No Integer Project ID. If this parameter is not set, the default project will be used.
VpcId No String VPC ID. If this parameter is not set, the classic network will be used. Please use the DescribeVpcs API to query the VPC list.
SubnetId No String VPC subnet ID. If UniqVpcId is set, then UniqSubnetId will be required. Please use the DescribeSubnets API to query the subnet list.
Password No String Instance password. If it is left empty, the password is in the default format of "instance ID+@+root account UIN". For example, if the instance ID is "cmgo-higv73ed" and the root account UIN "100000001", the instance password will be "cmgo-higv73ed@100000001". The custom password must contain 8-32 characters in at least two of the following types: letters, digits, and symbols (!@#%^*()_).
Tags.N No Array of TagInfo Instance tag information.
AutoRenewFlag No Integer Auto-renewal flag. Valid values: 0 (auto-renewal not enabled), 1 (auto-renewal enabled). Default value: 0.
AutoVoucher No Integer Whether to automatically use a voucher. Valid values: 1 (yes), 0 (no). Default value: 0.
Clone No Integer Instance type. Valid values: 1 (primary instance), 2 (temp instance), 3 (read-only instance), 4 (disaster recovery instance), 5 (cloned instance).
Father No String Primary instance ID. It is required for read-only, disaster recovery, and cloned instances.
SecurityGroup.N No Array of String Security group.
RestoreTime No String The point in time to which the cloned instance will be rolled back. This parameter is required for a cloned instance. The point in time in the format of 2021-08-13 16:30:00 must be within the last seven days.
InstanceName No String Instance name, which can contain up to 60 letters, digits, or symbols (_-).
AvailabilityZoneList.N No Array of String AZ list when multi-AZ deployment is enabled. For the specific purchasable versions which support multi-AZ deployment, please see the return result of the DescribeSpecInfo API. Notes: 1. Nodes of a multi-AZ instance must be deployed across three AZs. 2. To ensure a successful cross-AZ switch, you should not deploy most of the nodes to the same AZ. (For example, a three-node sharded cluster instance does not support deploying two or more nodes in the same AZ.) 3. MongoDB 4.2 and later versions do not support multi-AZ deployment. 4. Read-Only and disaster recovery instances do not support multi-AZ deployment. 5. Instances in the classic network do not support multi-AZ deployment.
MongosCpu No Integer The number of mongos CPUs, which is required for a sharded cluster instance of MongoDB 4.2 WiredTiger. For the specific purchasable versions supported, please see the return result of the DescribeSpecInfo API.
MongosMemory No Integer The size of mongos memory, which is required for a sharded cluster instance of MongoDB 4.2 WiredTiger. For the specific purchasable versions supported, please see the return result of the DescribeSpecInfo API.
MongosNodeNum No Integer The number of mongos routers, which is required for a sharded cluster instance of MongoDB 4.2 WiredTiger. For the specific purchasable versions supported, please see the return result of the DescribeSpecInfo API. Note: please purchase 3-32 mongos routers for high availability.
ReadonlyNodeNum No Integer Number of read-only nodes. Value range: 2-7.
ReadonlyNodeAvailabilityZoneList.N No Array of String The AZ where the read-only node is deployed
HiddenZone No String The AZ where the hidden node resides. It is required for cross-AZ instances.

3. Output Parameters

Parameter Name Type Description
DealId String Order ID.
InstanceIds Array of String List of IDs of created instances.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Creating a monthly subscribed TencentDB instance

This example shows you how to create a v4.0 instance. To create instances in other versions, specify the version you need as instructed in the input parameter description.

Input Example

POST / HTTP/1.1
Host: mongodb.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateDBInstance
<Common request parameters>

{
    "VpcId": "vpc-0akbol5v",
    "GoodsNum": 1,
    "Zone": "ap-guangzhou-2",
    "ProjectId": "0",
    "MachineCode": "HIO10G",
    "Period": "1",
    "ClusterType": "REPLSET",
    "Volume": 250,
    "MongoVersion": "MONGO_40_WT",
    "NodeNum": "3",
    "ReplicateSetNum": "1",
    "Memory": "4",
    "SubnetId": "subnet-fyrtjbqw",
    "Password": "pwd123456"
}

Output Example

{
    "Response": {
        "RequestId": "d88095e5-50e8-4245-a0cf-993a536f9b20",
        "DealId": "7142863",
        "InstanceIds": [
            "cmgo-po5f899l"
        ]
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
InvalidParameter Parameter error
InvalidParameter.PermissionDenied The current subaccount has no permission to perform this operation.
InvalidParameterValue.InvalidTradeOperation Billing error. Corresponding purchase/renewal/configuration change operations are not allowed for the current instance.
InvalidParameterValue.MachineTypeError Incorrect model.
InvalidParameterValue.MongoVersionError The instance version is incorrect.
InvalidParameterValue.NotFoundInstance The instance was not found.
InvalidParameterValue.PasswordRuleFailed The password is non-compliant.
InvalidParameterValue.ProjectNotFound The project does not exist.
InvalidParameterValue.RegionError Invalid region
InvalidParameterValue.ReplicaSetNumError Incorrect number of replica sets (shards).
InvalidParameterValue.SecondaryNumError Incorrect number of secondary nodes.
InvalidParameterValue.SpecNotOnSale Incorrect purchasable specification.
InvalidParameterValue.TagNotFound The specified tag was not found.
InvalidParameterValue.VpcIdOrSubnetIdNotFound The VPC (subnet) was not found.
InvalidParameterValue.ZoneClosed Instances are not purchasable in this AZ.
InvalidParameterValue.ZoneError Invalid availability zone
UnsupportedOperation.VersionNotSupport The current version does not support the operation.