Creating a DB Instance¶
Function¶
This API is used to create a single RDS DB instance, primary/standby DB instance, or read replica.
Before calling an API, you need to understand the API in Authentication.
Before calling this API, obtain the required region and endpoint.
URI¶
URI format
POST https://{Endpoint}/v3/{project_id}/instances
Parameter description
¶ Name
Mandatory
Description
project_id
Yes
Specifies the project ID of a tenant in a region.
For details about how to obtain the project ID, see Obtaining a Project ID.
Request¶
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. Its value can be any of the following: The DB instance name must be 4 to 64 characters long, start with a letter, and contain only letters (case-sensitive), digits, hyphens (-), and underscores (_). |
datastore | Yes | Object | Specifies the database information. For details, see Table 4. |
ha | No | Object | Specifies the HA configuration, which is used when you create primary/standby or cluster 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.
If this parameter is not set, the default value is as follows:
|
password | No | 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.
You are advised to enter a strong password to improve security, preventing security risks such as brute force cracking. |
backup_strategy | No | Object | Specifies the advanced backup policy. For details, see Table 6. |
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. Obtain the parameter value from the enterprise administrator. |
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. Obtain the parameter value from the enterprise administrator. |
vpc_id | Yes | String | Specifies the VPC ID. To obtain this parameter value, use either of the following methods:
|
subnet_id | Yes | String | Specifies the network ID. To obtain this parameter value, use either of the following methods:
|
data_vip | No | String | Specifies the floating IP address of a DB instance. To obtain this parameter value, use either of the following methods:
|
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:
|
charge_info | No | Object | Specifies the billing information. For details, see Table 8. |
time_zone | No | String | Specifies the UTC time zone.
|
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. |
Name | Mandatory | Type | Description |
---|---|---|---|
name | Yes | String | Specifies the DB instance name. The DB instance name of the same type must be unique for the same tenant. Valid value: The parameter must be 4 to 64 characters long, start with a letter, and contain only letters (case-sensitive), digits, hyphens (-), and underscores (_). |
replica_of_id | Yes | String | Specifies the primary DB instance ID for creating 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. Obtain the parameter value from the enterprise administrator. |
availability_zone | Yes | String | Specifies the AZ ID. The value cannot be empty. Obtain the parameter value from the enterprise administrator. |
charge_info | No | Object | Specifies the billing information. For details, see Table 8. |
Name | Mandatory | Type | Description |
---|---|---|---|
type | Yes | String | Specifies the DB engine. Value:
|
version | Yes | String | Specifies the database version.
For details about supported database versions, see section Querying Version Information About a DB Engine. |
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:
Note
|
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.
Example value:
|
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. Important NOTICE: Primary/standby DB instances of Microsoft SQL Server do not support disabling the automated backup policy. |
Name | Mandatory | Type | Description |
---|---|---|---|
type | Yes | String | Specifies the volume type. Its value can be any of the following and is case-sensitive:
|
size | Yes | Integer | Specifies the volume size. Its value must be a multiple of 10 and the value range is from 40 GB to 4,000 GB. Note For read replicas, this parameter is invalid. The volume size is the same as that of the primary DB instance by default. |
Name | Mandatory | Type | Description |
---|---|---|---|
charge_mode | Yes | String | Specifies the billing mode. Value: postPaid |
Note
The values of region and availability_zone are used as examples.
Request example
POST https://{Endpoint}/v3/0483b6b16e954cb88930a360d2c4e663/instances
Creating a single DB instance:
{ "name": "rds-instance-rep2", "datastore": { "type": "MySQL", "version": "5.6" }, "flavor_ref": "rds.mysql.s3.large.2", "volume": { "type": "ULTRAHIGH", "size": 100 }, "region": "aaa", "availability_zone": "bbb", "vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce", "subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f", "data_vip": "192.168.0.147", "security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5", "port": 8635, "backup_strategy": { "start_time": "08:15-09:15", "keep_days": 12 }, "charge_info": { "charge_mode": "postPaid" }, "password": "Test@12345678", "configuration_id": "452408-ef4b-44c5-94be-305145fg" , }
Creating primary/standby DB instances:
{ "name": "rds-instance-rep2", "datastore": { "type": "MySQL", "version": "5.6" }, "ha": { "mode": "ha", "replication_mode": "semisync" }, "flavor_ref": "rds.mysql.s3.large.2.ha", "volume": { "type": "ULTRAHIGH", "size": 100 }, "region": "aaa", "availability_zone": "bbb,ccc", "vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce", "subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f", "data_vip": "192.168.0.147", "security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5", "port": 8635, "backup_strategy": { "start_time": "08:15-09:15", "keep_days": 12 }, "charge_info": { "charge_mode": "postPaid" }, "password": "Test@12345678", "configuration_id": "452408-ef4b-44c5-94be-305145fg" }
Creating a Microsoft SQL Server cluster instance:
{ "name": "rds-2017EE-backup", "availability_zone": "bbb,ccc", "ha": { "mode": "ha", "replication_mode": "sync" }, "region": "aaa", "flavor_ref": "rds.mssql.s3.large.ha", "volume": { "type": "ULTRAHIGH", "size": 100 }, "disk_encryption_id": "", "vpc_id": "1fed5f32-3a8d-4385-84f4-aab78892f08b", "subnet_id": "1ceadde4-04c7-4b68-8b15-8683b03755df", "security_group_id": "bcbdf361-7cc2-4b8e-ace3-45f09187c326", "backup_strategy": { "keep_days": 7, "start_time": "01:00-02:00" }, "datastore": { "type": "sqlserver", "version": "2017_EE" }, "password": "Test@12345678", "enterprise_project_id": "", "time_zone": "UTC+08:00" }
Creating a read replica:
{ "name": "rds-instance-rep2", "replica_of_id": "afdsad-fds-fdsagin01", "flavor_ref": "rds.mysql.s3.large.2.rr", "volume": { "type": "ULTRAHIGH" }, "region": "aaa", "availability_zone": "bbb" }
Response¶
Normal response
¶ Name
Type
Description
instance
Object
Indicates the DB instance information.
For details, see Table 10.
job_id
String
Indicates the ID of the DB instance creation task.
¶ Name
Type
Description
id
String
Indicates the DB instance ID.
Note
The v3 DB instance ID is incompatible with the v1 DB instance ID.
name
String
Indicates the DB instance name. Indicates the DB instance name. DB instances of the same type can have same names under the same tenant.
Valid value:
For MySQL databases, the parameter must be 4 to 64 characters long, start with a letter, and contain only letters (case-sensitive), digits, hyphens (-), and underscores (_).
For PostgreSQL and Microsoft SQL Server databases, the parameter must be 4 to 64 characters long, start with a letter, and contain only letters (case-sensitive), digits, hyphens (-), and underscores (_).
status
String
Indicates the DB instance status. For example, BUILD indicates that the DB instance is being created.
For details, see status in Table 3.
datastore
Object
Indicates the database information.
For details, see Table 11.
ha
Object
Indicates the HA configuration parameters.
For details, see Table 12.
configuration_id
String
Indicates the parameter template ID. This parameter is returned only when a custom parameter template is used during DB instance creation.
port
String
Indicates the database port, which is the same as the request parameter.
backup_strategy
Object
Indicates the automated backup policy.
For details, see Table 13.
flavor_ref
String
Indicates the specification code. The value cannot be empty.
For details, see spec_code in Table 3 in section Querying Database Specifications.
volume
Object
Indicates the volume information.
For details, see Table 14.
region
String
Indicates the region ID.
availability_zone
String
Indicates the AZ ID.
vpc_id
String
Indicates 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
String
Indicates 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 in the Virtual Private Cloud API Reference.
security_group_id
String
Indicates 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
Object
Indicates the billing information.
For details, see Table 15.
collation
String
Indicates the collation set for Microsoft SQL Server.
¶ Name
Type
Description
type
String
Indicates the DB engine. Value:
MySQL
PostgreSQL
SQLServer
version
String
Indicates the database version.
For details about supported database versions, see section Querying Version Information About a DB Engine.
¶ Name
Type
Description
mode
String
Indicates the primary/standby or cluster instance type. The value is Ha.
replication_mode
String
Indicates the replication mode for the standby DB instance. This parameter is valid when the mode is Ha.
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.
¶ Name
Type
Description
start_time
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
If backup_strategy in the request body is empty, 02:00-03:00 is returned for start_time by default.
keep_days
Integer
Indicates 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.
If backup_strategy in the request body is empty, 7 is returned for keep_days by default.
¶ Name
Type
Description
type
String
Indicates the volume type.
Its value can be any of the following and is case-sensitive:
ULTRAHIGH: indicates the SSD type.
size
Integer
Indicates the volume size.
Its value range is from 40 GB to 4,000 GB. The value must be a multiple of 10.
¶ Name
Type
Description
charge_mode
String
Indicates the billing mode.
Value: postPaid
Note
The values of region and availability_zone are used as examples.
Example normal response
Creating a single MySQL DB instance:
{ "instance": { "id": "dsfae23fsfdsae3435in01", "name": "trove-instance-rep2", "datastore": { "type": "MySQL", "version": "5.6" }, "flavor_ref": "rds.mysql.s3.large.2", "volume": { "type": "ULTRAHIGH", "size": 100 }, "region": "aaa", "availability_zone": "bbb", "vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce", "subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f", "security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5", "port": "8635", "backup_strategy": { "start_time": "08:15-09:15", "keep_days": 3 }, "configuration_id": "452408-44c5-94be-305145fg", "charge_info": { "charge_mode": "postPaid" } }, "job_id": "dff1d289-4d03-4942-8b9f-463ea07c000d" }
Creating primary/standby DB instances:
{ "instance":{ "id": "dsfae23fsfdsae3435in01", "name": "trove-instance-rep2", "datastore": { "type": "MySQL", "version": "5.6" }, "ha": { "mode": "ha", "replication_mode": "semisync" }, "flavor_ref": "rds.mysql.s3.large.2.ha", "volume": { "type": "ULTRAHIGH", "size": 100 }, "region": "aaa", "availability_zone": "bbb,ccc", "vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce", "subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f", "security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5", "port": "8635", "backup_strategy": { "start_time": "08:15-09:15", "keep_days": 3 }, "configuration_id": "452408-44c5-94be-305145fg", "charge_info": { "charge_mode": "postPaid" }, }, "job_id": "dff1d289-4d03-4942-8b9f-463ea07c000d" }
Creating a Microsoft SQL Server cluster instance:
{ "instance": { "id": "5e6724ebd1d242d2a5540e52a97886eain04", "name": "rds-2017EE-backup", "status": "BUILD", "datastore": { "type": "SQLServer", "version": "2017_EE" }, "ha": { "mode": "Ha", "replication_mode": "sync" }, "port": "1433", "volume": { "type": "ULTRAHIGH", "size": 100 }, "region": "aaa", "backup_strategy": { "start_time": "01:00-02:00", "keep_days": 7 }, "disk_encryption_id": "", "flavor_ref": "rds.mssql.s3.large.ha", "availability_zone": "bbb,ccc", "vpc_id": "1fed5f32-3a8d-4385-84f4-aab78892f08b", "subnet_id": "1ceadde4-04c7-4b68-8b15-8683b03755df", "security_group_id": "bcbdf361-7cc2-4b8e-ace3-45f09187c326", "charge_info": { "charge_mode": "postPaid" } }, "job_id": "5ac7d0cf-7dd2-457b-bf32-1475c426f2e5" }
Creating a read replica:
{ "instance":{ "id": "dsfae23fsfdsae3435in01", "name": "trove-instance-rep2", "flavor_ref": "rds.mysql.s3.large.2.rr", "volume": { "type": "ULTRAHIGH", "size": 100 }, "region": "aaa", "availability_zone": "bbb", "vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce", "subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f", "security_group_id": "2a1f7fc8-3307-42a7-aa6f-42c8b9b8f8c5", "port": "8635", "configuration_id": "452408-44c5-94be-305145fg" }, "job_id": "dff1d289-4d03-4942-8b9f-463ea07c000d" }
Abnormal response
For details, see Abnormal Request Results.
Status Code¶
Normal
202
Abnormal
For details, see Status Codes.
Error Code¶
For details, see Error Codes.