CreateDBInstance

Updated at:

Creates or clones an ApsaraDB for MongoDB replica set instance.

Operation description

Before you call this operation, make sure that you fully understand the billing methods and pricing of ApsaraDB for MongoDB.

For more information about ApsaraDB for MongoDB instance specifications, see Instance specifications.

To create a sharded cluster instance, call the CreateShardingDBInstance operation.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dds:CreateDBInstance

create

*Instance

acs:dds:{#regionId}:{#accountId}:dbinstance/*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID. You can call the DescribeRegions operation to query the region ID.

Note

When you call this operation to clone clone instance or restore clone instance from the recycle bin, the value of this parameter must be the same as that of the source instance.

cn-hangzhou

ClientToken

string

No

The client token that is used to ensure the idempotence of the request and prevent duplicate submissions. You can generate the value of this parameter on the client side. The value must be unique across different requests and can be up to 64 ASCII characters in length. The value cannot contain non-ASCII characters.

ETnLKlblzczshOTUbOCz****

ZoneId

string

No

Specifies whether to perform a dry run on the request. Valid values:

  • true: performs a dry run without calling the operation. The system checks items such as request parameters, request format, business limits, and inventory. If the check fails, the corresponding error is returned. If the check succeeds, the DryRunOperation error code is returned.

  • false (default): sends a normal request. After the check succeeds, the operation is directly executed.

cn-hangzhou-g

EngineVersion

string

Yes

The zone ID. You can call the DescribeRegions operation to query the zone ID.

Valid values:

  • 4.0 :

    MongoDB 4.0

  • 5.0 :

    MongoDB 5.0

  • 4.2 :

    MongoDB 4.2

  • 6.0 :

    MongoDB 6.0

  • 3.4 :

    MongoDB 3.4

  • 7.0 :

    MongoDB 7.0

  • 4.4 :

    MongoDB 4.4

  • 8.0 :

    MongoDB 8.0

  • 8.3 :

    MongoDB 8.3

cn-hangzhou-g

DBInstanceClass

string

Yes

The database engine version. Valid values:

  • 8.0

  • 7.0

  • 6.0

  • 5.0

  • 4.4

  • 4.2

  • 4.0

Note

When you call this operation to clone clone instance or restore clone instance from the recycle bin, the value of this parameter must be the same as that of the source instance.

Warning Versions 3.4 and earlier are no longer available for sale.

4.4

DBInstanceStorage

integer

Yes

The instance type. You can call the DescribeAvailableResource operation to query the available instance types.

dds.mongo.standard

DBInstanceDescription

string

No

The instance storage. Unit: GB.

The valid values are subject to the instance type. For details, see Replica set instance types.

10

SecurityIPList

string

No

The name of the instance. The name must meet the following requirements:

  • It must start with a letter or a Chinese character.

  • It can contain digits, letters, Chinese characters, underscores (_), periods (.), and hyphens (-).

  • It must be 2 to 256 characters in length.

test

AccountPassword

string

No

The IP address whitelist of the instance. Separate multiple IP addresses with commas (,). Duplicate IP addresses are not allowed. The following three formats are supported:

  • 0.0.0.0/0

  • IP address format, such as 10.23.12.24.

  • CIDR format, such as 10.23.12.0/24. 24 indicates the length of the prefix in the CIDR block, and the valid range is 1 to 32.

Note
  • You can add up to 1,000 IP addresses or CIDR blocks to each instance. The total number of IP addresses or CIDR blocks in all IP address whitelist groups cannot exceed 1,000.

  • 0.0.0.0/0 indicates that all IP addresses can access the databases of the instance. This is a high-risk setting. Proceed with caution.

192.168.xx.xx,192.168.xx.xx

Period

integer

No

The password of the root account. The password must meet the following requirements:

  • It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.

  • Special characters include !@#$%^&*()_+-=.

  • It must be 8 to 32 characters in length.

Note

For more information about how to resolve the issue where database connection fails due to special characters in the account password in the connection string, see What do I do if the connection to an ApsaraDB for MongoDB instance fails because the username or password in the connection string contains special characters?.

123456Aa

ChargeType

string

No

The subscription duration of the instance. Unit: month.

Valid values: 1 to 9 (integers), 12, 24, 36, and 60.

Note

This parameter is required and valid only when the ChargeType parameter is set to PrePaid.

Valid values:

  • PostPaid :

    pay-as-you-go.

  • PrePaid :

    subscription.

1

NetworkType

string

No

The billing method of the instance. Valid values:

  • PostPaid: pay-as-you-go. This is the default value.

  • PrePaid: subscription.

Note

When this parameter is set to PrePaid, you must also specify the Period parameter.

Valid values:

  • VPC :

    Virtual Private Cloud.

PrePaid

VpcId

string

No

The network type of the instance. Valid values:

VPC: Virtual Private Cloud (VPC).

VPC

VSwitchId

string

No

The VPC ID.

vpc-bp175iuvg8nxqraf2****

SrcDBInstanceId

string

No

The vSwitch ID.

vsw-bp1gzt31twhlo0sa5****

BackupId

string

No

The source instance ID.

Note

When you call this operation to clone an instance, you must specify this parameter and the BackupId or RestoreTime parameter. When you call this operation to restore a revoked instance, you only need to specify this parameter, and you do not need to specify the BackupId or RestoreTime parameter.

dds-bp1ee12ad351****

RestoreTime

string

No

The ID of the backup set. You can call the DescribeBackups operation to query the backup set ID.

Note

This parameter is required only when you call this operation to clone an instance from a backup set. You must also specify the SrcDBInstanceId parameter.

32994****

BusinessInfo

string

No

The point in time to which you want to restore the instance. You can specify any point in time within the last seven days. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Note

This parameter is required only when you call this operation to clone an instance to a specific point in time. You must also specify the SrcDBInstanceId parameter.

2022-03-13T12:11:14Z

AutoRenew

string

No

The additional parameter for business information.

{“ActivityId":"000000000"}

DatabaseNames

string

No

Specifies whether to enable auto-renewal for the instance. Valid values:

  • true: enables auto-renewal.

  • false: disables auto-renewal. In this case, you must manually renew the instance. This is the default value.

Note

This parameter is valid and optional only when the ChargeType parameter is set to PrePaid.

true

CouponNo

string

No

The name of the database.

Note

When you call this operation to clone an instance, you can specify this parameter to specify the databases to be cloned. If you do not specify this parameter, all databases of the instance are cloned.

mongodbtest

StorageEngine

string

No

Specifies whether to use a coupon. Valid values:

  • default or null: uses a coupon. This is the default value.

  • youhuiquan_promotion_option_id_for_blank: does not use a coupon.

Valid values:

  • WiredTiger :

    WiredTiger storage engine.

default

ReplicationFactor

string

No

The storage engine of the instance. Set the value to WiredTiger.

Note
  • When you call this operation to clone clone instance or restore clone instance from the recycle bin, the value of this parameter must be the same as that of the source instance.

  • For more information about the constraints on the selection of storage engines and versions, see Versions and storage engines.

WiredTiger

ReadonlyReplicas

string

No

The number of primary and secondary nodes in the replica set instance. Valid values:

  • 3 (default)

  • 5

  • 7

Important You do not need to specify this parameter for a standalone instance.

3

Engine

string

No

The number of read-only nodes in the replica set instance. Valid values: 0 to 5 (integers). Default value: 0.

Valid values:

  • MongoDB :

    MongoDB database engine.

0

StorageType

string

No

The resource group ID.

rg-acfmyiu4ekp****

SecondaryZoneId

string

No

The dedicated cluster ID.

dhg-2x78****

HiddenZoneId

string

No

The database engine. Set the value to MongoDB.

MongoDB

Tag

array<object>

No

The storage type. Valid values:

  • cloud_essd1: PL1 ESSD.

  • cloud_essd2: PL2 ESSD.

  • cloud_essd3: PL3 ESSD.

  • cloud_auto: ESSD AutoPL cloud disk.

  • local_ssd: local SSD.

Note
  • If you specify cloud_essd1 when you purchase a standalone instance, the instance actually uses a cloud_essd cloud disk.

  • ESSD AutoPL cloud disks are supported only on the Alibaba Cloud China site.

  • The default value for instances of version 4.4 and later is cloud_essd1.

  • The default value for instances of version 4.2 and earlier is local_ssd.

cloud_essd1

object

No

Key

string

No

The tag key.

Note
  • N indicates the sequence number of the tag key. For example, Tag.1.Key indicates the key of the first tag, and Tag.2.Key indicates the key of the second tag.

testdatabase

Value

string

No

The tag value.

Note

N indicates the sequence number of the tag value. For example, Tag.1.Value indicates the value of the first tag, and Tag.2.Value indicates the value of the second tag.

apitest

GlobalSecurityGroupIds

string

No

The zone where the secondary node resides. You can specify this parameter for multi-zone deployment. Valid values:

  • cn-hangzhou-g: Hangzhou Zone G.

  • cn-hangzhou-h: Hangzhou Zone H.

  • cn-hangzhou-i: Hangzhou Zone I.

  • cn-hongkong-b: Hong Kong (China) Zone B.

  • cn-hongkong-c: Hong Kong (China) Zone C.

  • cn-hongkong-d: Hong Kong (China) Zone D.

  • cn-wulanchabu-a: Ulanqab Zone A.

  • cn-wulanchabu-b: Ulanqab Zone B.

  • cn-wulanchabu-c: Ulanqab Zone C.

  • ap-southeast-1a: Singapore Zone A.

  • ap-southeast-1b: Singapore Zone B.

  • ap-southeast-1c: Singapore Zone C.

  • ap-southeast-5a: Jakarta Zone A.

  • ap-southeast-5b: Jakarta Zone B.

  • ap-southeast-5c: Jakarta Zone C.

  • eu-central-1a: Frankfurt Zone A.

  • eu-central-1b: Frankfurt Zone B.

  • eu-central-1c: Frankfurt Zone C.

Note
  • This parameter is active only when the instance uses cloud disks.

  • The value of this parameter cannot be the same as the value of the ZoneId or HiddenZoneId parameter.

cn-hangzhou-h

Encrypted

boolean

No

The zone where the hidden node resides. You can specify this parameter for multi-zone deployment. Valid values:

  • cn-hangzhou-g: Hangzhou Zone G.

  • cn-hangzhou-h: Hangzhou Zone H.

  • cn-hangzhou-i: Hangzhou Zone I.

  • cn-hongkong-b: Hong Kong (China) Zone B.

  • cn-hongkong-c: Hong Kong (China) Zone C.

  • cn-hongkong-d: Hong Kong (China) Zone D.

  • cn-wulanchabu-a: Ulanqab Zone A.

  • cn-wulanchabu-b: Ulanqab Zone B.

  • cn-wulanchabu-c: Ulanqab Zone C.

  • ap-southeast-1a: Singapore Zone A.

  • ap-southeast-1b: Singapore Zone B.

  • ap-southeast-1c: Singapore Zone C.

  • ap-southeast-5a: Jakarta Zone A.

  • ap-southeast-5b: Jakarta Zone B.

  • ap-southeast-5c: Jakarta Zone C.

  • eu-central-1a: Frankfurt Zone A.

  • eu-central-1b: Frankfurt Zone B.

  • eu-central-1c: Frankfurt Zone C.

Note
  • This parameter is active only when the instance uses cloud disks.

  • The value of this parameter cannot be the same as the value of the ZoneId or SecondaryZoneId parameter.

cn-hangzhou-i

EncryptionKey

string

No

The custom tags.

2axxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

ProvisionedIops

integer

No

The global IP address whitelist templates of the instance. Separate multiple templates with commas (,). Duplicate templates are not allowed. This feature is in canary release.

g-qxieqf40xjst1ngpr3jz

RestoreType

string

No

Specifies whether to enable cloud disk encryption.

Valid values:

  • 0
  • 1
  • 2
  • 3
  • 4

true

SrcRegion

string

No

The ID of the custom key.

2axxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Response elements

Element

Type

Description

Example

object

DBInstanceId

string

The instance ID.

dds-bp144a7f2db8****

OrderId

string

The order ID.

21077576248****

RequestId

string

The request ID.

D8F1D721-6439-4257-A89C-F1E8E9C9****

Examples

Success response

JSON format

{
  "DBInstanceId": "dds-bp144a7f2db8****",
  "OrderId": "21077576248****",
  "RequestId": "D8F1D721-6439-4257-A89C-F1E8E9C9****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 SecurityRisk.AuthVerification we have detected a risk with your default payment method. An email and notification has been sent to you. Please re-submit your order before after verificaiton.
400 MissingParameter Period is mandatory for this action.
400 ORDER.ACCOUNT_INFORMATION_INCOMPLETE Your information is incomplete. Complete your information before ordering.
400 InvalidClientToken.Malformed Specified parameter ClientToken is not valid.
400 InvalidDBInstanceDescription.Malformed Specified parameter DBInstanceDescription is not valid. Invalid node name.
400 InvalidSecurityIPListLength.Malformed The quota of security ip exceeds.
400 InsufficientBalance Your account does not have enough balance. The payment failed. Please add another payment method. You can also top up or add funds to your account.
400 QuotaExceed.AfterpayInstance Living afterpay instances quota exceeded.
400 InvalidCapacity.NotFound The Capacity provided does not exist in our records. The specified storage capacity is invalid. Specify a storage capacity within a valid range. Unit: MB.
400 ResourceNotAvailable Resource you requested is not available for finance user.
400 IdempotentParameterMismatch Request uses a client token in a previous request but is not identical to that request. The specified ClientToken parameter is already in use. Specify a client token that has not been used. The ClientToken value is generated by the client and must be unique among different requests. The value can be up to 64 ASCII characters in length and cannot contain non-ASCII characters.
400 InvalidSecurityIPList.Malformed The specified parameter "SecurityIPList" is not valid.
400 InvalidSecurityIPList.Duplicate The Security IP address is not in the available range or occupied.
400 InvalidDBInstanceStorage.ValueNotSupported The specified parameter DBInstanceStorage is not valid.
400 InvalidAccountPassword.Malformed Specified parameter AccountPassword is not valid.
400 TokenServiceError Duplicate ClientToken request.
400 Zone.Closed The specified zone is closed.
400 PRICE.ORIGIN_PRICE_ERROR The origin price error.
400 NO_AVAILABLE_PAYMENT_METHOD No payment method is specified for your account. We recommend that you add a payment method.
400 InvalidEcsImage.NotFound Specified ecs image does not exist.
400 SaleValidateNoSpecificCodeFailed Specified Storage or Version or InstanceClass is invalid. Storage or Version or InstanceClass is empty.
400 Trade_Not_Support_Async_Pay Trade not support async pay.
400 InvalidZoneld The specified primary zone, secondary zone and hidden zone cannot be the same. The parameters of the primary zone, secondary zone and hidden zone cannot be the same.
400 SameZoneId The specified primary zone, secondary zone require two different zones. The specified primary zone, secondary zone require two different zones.
403 RealNameAuthenticationError Your account has not passed the real-name authentication yet. Real-name verification has not been completed for the Alibaba Cloud account. Complete real-name verification and try again.
403 RegionUnauthorized There is no authority to create instance in the specified region.
403 OperationDenied The resource is out of usage. The resource is out of usage.
403 InvalidEngineVersionInRegion.NotAvailable The EngineVersion in the Region is not available.
403 InvalidBackupLogStatus Current backup log enable status does not support this operation.
403 IncorrectBackupSetState Current backup set state does not support operations.
404 InvalidBackup.NotFound The available backup does not exist in recovery time.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.