Creating a DB Instance

Function

This API is used to create a single RDS DB instance, primary/standby DB instances, or a read replica.

URI

Request

Table 2 Parameter description (creating single and primary/standby DB instances)

Name

Mandatory

Type

Description

name

Yes

String

Specifies the DB instance name.

DB instances of the same type can have same names under the same tenant.

The value must be 4 to 64 characters in length and start with a letter. It is case-sensitive and can contain only letters, digits, hyphens (-), and underscores (_).

datastore

Yes

Object

Specifies the database information.

For details, see Table 4.

ha

No

Object

Specifies the HA configuration parameters, which are used when creating primary/standby DB instances.

For details, see Table 5.

configuration_id

No

String

Specifies the parameter template ID.

For details, see id in Table 3 in section Obtaining a Parameter Template List.

port

No

String

Specifies the database port information.

  • The MySQL database port ranges from 1024 to 65535 (excluding 12017 and 33071, which are occupied by the RDS system and cannot be used).
  • The PostgreSQL database port ranges from 2100 to 9500.
  • The Microsoft SQL Server database port is 1433 or ranges from 2100 to 9500 (excluding 5355 and 5985).

If this parameter is not set, the default value is as follows:

  • For MySQL, the default value is 3306.
  • For PostgreSQL, the default value is 5432.
  • For Microsoft SQL Server, the default value is 1433.

password

Yes

String

Specifies the database password.

Valid value:

A database password must be 8 to 32 characters long and contain at least three types of the following characters: uppercase letters, lowercase letters, digits, and special characters.

Different DB engines support different special characters.

  • RDS for MySQL: ~!@#$%^*-_=+?,()&
  • RDS for PostgreSQL: ~!@#$%^*-_=+?,
  • RDS for SQL Server: ~!@#$%^*-_+?,

You are advised to enter a strong password to improve security, preventing security risks such as brute force cracking. If the password you provide is regarded as a weak password by the system, you will be prompted to enter a stronger password.

backup_strategy

No

Object

Specifies the advanced backup policy.

For details, see Table 6.

disk_encryption_id

No

String

Specifies the key ID for disk encryption. The default value is empty.

flavor_ref

Yes

String

Specifies the specification code. The value cannot be empty.

For details, see spec_code in Table 3 in section Querying Database Specifications.

volume

Yes

Object

Specifies the volume information.

For details, see Table 7.

region

Yes

String

Specifies the region ID.

The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints.

availability_zone

Yes

String

Specifies the AZ ID. If the DB instance is not a single instance, you need to specify an AZ for each node of the instance and separate the AZs with commas (,). For details, see the example.

The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints.

vpc_id

Yes

String

Specifies the VPC ID. To obtain this parameter value, use either of the following methods:

  • Method 1: Log in to VPC console and view the VPC ID in the VPC details.
  • Method 2: See the "Querying VPCs" section in the Virtual Private Cloud API Reference.

subnet_id

Yes

String

Specifies the network ID. To obtain this parameter value, use either of the following methods:

  • Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page.
  • Method 2: See the "Querying Subnets" section under "APIs" or the "Querying Networks" section under "OpenStack Neutron APIs" in Virtual Private Cloud API Reference.

data_vip

No

String

Specifies the private IP address of a DB instance. You can use the following methods to obtain the private IP address:

  • Method 1: Log in to VPC console and click the target subnet on the Subnets page. You can view the subnet CIDR block on the displayed page.
  • Method 2: See the "Querying Subnets" section under "APIs" in the Virtual Private Cloud API Reference.

security_group_id

Yes

String

Specifies the security group which the RDS DB instance belongs to. To obtain this parameter value, use either of the following methods:

  • Method 1: Log in to VPC console. Choose Access Control > Security Groups in the navigation pane on the left. On the displayed page, click the target security group. You can view the security group ID on the displayed page.
  • Method 2: See the "Querying Security Groups" section in the Virtual Private Cloud API Reference.

charge_info

No

Object

Specifies the billing information, which is pay-per-use. By default, pay-per-use is used.

For details, see Table 8.

unchangeable_param

No

Object

Specifies the list of unchangeable parameters. The unchangeable parameters need to be specified before database initialization and cannot be modified after being specified.

For details, see Table 9.

collation

No

String

This parameter applies only to Microsoft SQL Server DB instances.

Value range: character sets queried in Querying the Available SQL Server Character Set.

Table 3 Parameter for Replica creation (For Microsoft SQL Server, Only 2022_EE, 2019_EE and 2017_EE support the creation of read replicas and do not support the creation of single DB instances.)

Name

Mandatory

Type

Description

name

Yes

String

Specifies the DB instance name.

DB instances of the same type can have same names under the same tenant.

The value must be 4 to 64 characters in length and start with a letter. It is case-sensitive and can contain only letters, digits, hyphens (-), and underscores (_).

replica_of_id

Yes

String

Specifies the DB instance ID, which is used to create a read replica.

For details, see id in Table 3 in section Querying Details About DB Instances.

disk_encryption_id

No

String

Specifies the key ID for disk encryption. The default value is empty.

flavor_ref

Yes

String

Specifies the specification code. The value cannot be empty.

For details, see spec_code in Table 3 in section Querying Database Specifications.

volume

Yes

Object

Specifies the volume information.

For details, see Table 7.

region

No

String

Specifies the region ID. Currently, read replicas can be created only in the same region as that of the primary DB instance.

The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints.

availability_zone

Yes

String

Specifies the AZ ID.

The value cannot be empty. For details about how to obtain this parameter value, see Regions and Endpoints.

charge_info

No

Object

Specifies the billing information, which is pay-per-use. By default, pay-per-use is used.

For details, see Table 8.

Table 4 datastore field data structure description

Name

Mandatory

Type

Description

type

Yes

String

Specifies the DB engine. Value:

  • MySQL
  • PostgreSQL
  • SQLServer

version

Yes

String

Specifies the database version.

  • MySQL databases support 5.6, 5.7, and 8.0. Example value: 5.7
  • PostgreSQL databases support 11, 12, 13, 14, 15 and 16. Example value: 11
  • Microsoft SQL Server databases only support 2017_SE, 2017_EE, 2019_SE, 2019_EE, 2022_SE and 2022_EE. Example value: 2017_SE

For details about supported database versions, see section Querying Version Information About a DB Engine.

Table 5 ha field data structure description

Name

Mandatory

Type

Description

mode

Yes

String

Specifies the primary/standby or cluster instance type. The value is Ha (case-insensitive).

replication_mode

Yes

String

Specifies the replication mode for the standby DB instance.

Value:

  • For MySQL, the value is async or semisync.
  • For PostgreSQL, the value is async or sync.
  • For Microsoft SQL Server, the value is sync.
NOTE:
  • async indicates the asynchronous replication mode.
  • semisync indicates the semi-synchronous replication mode.
  • sync indicates the synchronous replication mode.
Table 6 backupStrategy field data structure description

Name

Mandatory

Type

Description

start_time

Yes

String

Specifies the backup time window. Automated backups will be triggered during the backup time window.

The value cannot be empty. It must be a valid value in the "hh:mm-HH:MM" format. The current time is in the UTC format.

  • The HH value must be 1 greater than the hh value.
  • The values of mm and MM must be the same and must be set to any of the following: 00, 15, 30, or 45.

Example value:

  • 08:15-09:15
  • 23:00-00:00

keep_days

No

Integer

Specifies the retention days for specific backup files.

The value range is from 0 to 732. If this parameter is not specified or set to 0, the automated backup policy is disabled. To extend the retention period, contact customer service. Automated backups can be retained for up to 2562 days.

NOTICE:

Primary/standby DB instances and Cluster DB instances of Microsoft SQL Server do not support disabling the automated backup policy.

Table 7 volume field data structure description

Name

Mandatory

Type

Description

type

Yes

String

Specifies the volume type.

Its value can be any of the following and is case-sensitive:

  • COMMON: SATA storage.
  • ULTRAHIGH: ultra-high I/O storage.
  • CLOUDSSD: cloud SSD storage.
  • ESSD: extreme SSD storage.
NOTE:
  • The MySQL and PostgreSQL DB engines support the following volume types: CLOUDSSD and ESSD. ESSD is not supported for Single instance types for MySQL and PostgreSQL.
  • The SQL Server engine supports the following volume types: COMMON, ULTRAHIGH, and ESSD.

size

Yes

Integer

Specifies the volume size.

Its value must be a multiple of 10 and the value range is from 40 GB to 4000 GB.

NOTE:

For read replicas, this parameter is invalid. The volume size is the same as that of the primary DB instance by default.

Table 8 chargeInfo field data structure description

Name

Mandatory

Type

Description

charge_mode

Yes

String

Specifies the billing mode.

The value postPaid indicates the pay-per-use billing mode.

Table 9 unchangeable_param field data structure description

Parameter

Mandatory

Type

Description

lower_case_table_names

No

String

Whether table names are case sensitive. The default value is 1.

Value range:

  • 0: Table names are fixed and case sensitive.
  • 1: Table names are stored in lowercase and are case insensitive.
NOTE:

When data is restored to an existing DB instance, the case sensitivity setting of the existing DB instance must be the same as that of the original DB instance. Otherwise, the restoration may fail.

Response

Status Code

Error Code

For details, see Error Codes.