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, learn about request header parameters.
URI
- URI format
- Parameter description
Table 1 Parameters Parameter
Mandatory
Description
project_id
Yes
Project ID of a tenant in a region.
For details about how to obtain the project ID, see Obtaining a Project ID.
Request
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | DB instance name. Instances of the same type can have the same name under the same tenant.
|
| datastore | Yes | Object | Database information. For details, see Table 4. |
| flavor_ref | Yes | String | Specification code. The value cannot be left blank. For details, see spec_code in Table 3 of section Querying Database Specifications. |
| volume | Yes | Object | Instance storage. For details, see Table 7. |
| region | Yes | String | Region ID. The value cannot be left blank. For details about how to obtain this parameter value, see Regions and Endpoints. |
| availability_zone | Yes | String | 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 left blank. For details about how to obtain this parameter value, see Regions and Endpoints. |
| vpc_id | Yes | String | VPC ID. To obtain this parameter value, use either of the following methods:
|
| subnet_id | Yes | String | Subnet ID. To obtain this parameter value, use either of the following methods:
|
| security_group_id | Yes | String | Security group which the DB instance belongs to. To obtain this parameter value, use either of the following methods:
|
| ha | No | Object | HA configuration, which is used when you create primary/standby instances. For details, see Table 5. |
| configuration_id | No | String | Parameter template ID. For details, see id in Table 3 in section Obtaining a Parameter Template List. |
| port | No | String | Database port information.
If this parameter is not set, the default value is as follows:
|
| password | No | String | Database password. Range 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. 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 | Advanced backup policy. For details, see Table 6. |
| data_vip | No | String | Floating IP address of a DB instance. You can use the following methods to obtain the floating IP address:
|
| time_zone | No | String | UTC time zone.
|
| tags | No | Array of objects | Tag list. Each DB instance can be associated with tag key–value pairs while being created.
If you want to create DB instances with multiple tag key–value pairs, separate them with commas (,). A maximum of 10 key–value pairs can be added. For details, see Table 8. |
| collation | No | String | This parameter applies only to RDS for SQL Server DB instances. Value range: character sets queried in Querying the Available SQL Server Character Set. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | DB instance name. The DB instance name of the same type must be unique for the same tenant. Valid value:
|
| flavor_ref | Yes | String | Specification code. The value cannot be left blank. For details, see spec_code in Table 3 of section Querying Database Specifications. |
| volume | Yes | Object | Volume information. For details, see Table 7. |
| availability_zone | Yes | String | AZ ID. The value cannot be left blank. For details about how to obtain this parameter value, see Regions and Endpoints. |
| region | No | String | Region ID. Currently, read replicas can be created only in the same region as that of the primary DB instance. The value cannot be left blank. For details about how to obtain this parameter value, see Regions and Endpoints. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| type | Yes | String | DB engine. Value:
|
| version | Yes | String | Database version.
For details about supported database versions, see section Querying Version Information About a DB Engine. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| mode | Yes | String | Primary/standby instance type. The value is HA (case-insensitive). |
| replication_mode | Yes | String | Replication mode for the standby DB instance. Value:
NOTE:
|
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| start_time | Yes | String | Backup time window. Automated backups will be triggered during the backup time window. The value cannot be left blank. 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 | 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. NOTICE: Primary/standby DB instances of RDS for SQL Server do not support disabling the automated backup policy. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| type | Yes | String | Storage type. Its value can be any of the following and is case-sensitive:
|
| size | Yes | Integer | Storage 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 storage size is the same as that of the primary DB instance by default. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key | Yes | String | Tag key. It must consist of 1 to 128 Unicode characters, including letters, digits, spaces, and special characters _.:=+-@. However, it cannot start or end with a space, or start with _sys_. It can contain uppercase and lowercase letters, digits, hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF). |
| value | Yes | String | Tag value. It can be left blank or contain a maximum of 255 Unicode characters, including letters, digits, spaces, and the following special characters: _.:=+-@ It can contain uppercase and lowercase letters, digits, periods (.), hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF). |
Example Request
- Creating an RDS for MySQL single-node instance
POST https://{endpoint}/v3/0483b6b16e954cb88930a360d2c4e663/instances { "name": "rds-instance-rep2", "datastore": { "type": "MySQL", "version": "5.7" }, "flavor_ref": "rds.mysql.s1.large", "volume": { "type": "ULTRAHIGH", "size": 100 }, "vpc_id": "490a4a08-ef4b-44c5-94be-3051ef9e4fce", "subnet_id": "0e2eda62-1d42-4d64-a9d1-4e9aa9cd994f", "data_vip": "192.168.0.1", "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": "****", "configuration_id": "452408-ef4b-44c5-94be-305145fg" "time_zone": "UTC+04:00" }
- Creating an RDS for MySQL primary/standby instance
{ "name": "rds-instance-rep2", "datastore": { "type": "MySQL", "version": "5.7" }, "ha": { "mode": "ha", "replication_mode": "semisync" }, "flavor_ref": "rds.mysql.s1.large.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.1", "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": "****", "configuration_id": "452408-ef4b-44c5-94be-305145fg" }
- Creating a read replica for an RDS for MySQL instance
{ "name": "rds-instance-rep2", "replica_of_id": "afdsad-fds-fdsagin01", "flavor_ref": "rds.mysql.s1.large.rr", "volume": { "type": "ULTRAHIGH" }, "region": "aaa", "availability_zone": "bbb" }
Response
- Normal response
Table 9 Parameters Parameter
Type
Description
instance
Object
DB instance information.
For details, see Table 10.
job_id
String
ID of the DB instance creation task.
Table 10 instance field data structure description Parameter
Type
Description
id
String
DB instance ID.
NOTE:The v3 DB instance ID is incompatible with the v1 DB instance ID.
name
String
DB instance name. Instances of the same type can have the same name under the same tenant.
status
String
DB instance status. For example, BUILD indicates that the DB instance is being created.
datastore
Object
Database information.
For details, see Table 11.
ha
Object
HA configuration parameters. This parameter is returned only when primary/standby DB instances are created.
For details, see Table 12.
configuration_id
String
Parameter template ID. This parameter is returned only when a custom parameter template is used during DB instance creation.
port
String
Database port, which is the same as the request parameter.
backup_strategy
Object
Automated backup policy.
For details, see Table 13.
flavor_ref
String
Specification code. The value cannot be left blank.
For details, see spec_code in Table 3 of section Querying Database Specifications.
volume
Object
Volume information.
For details, see Table 14.
region
String
Region ID.
availability_zone
String
AZ ID.
vpc_id
String
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
Subnet ID. To obtain this parameter value, use either of the following methods:
- Method 1: Log in to the 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
Security group which the 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
Billing information.
For details, see Table 15.
collation
String
Collation set for RDS for SQL Server.
Table 11 datastore field data structure description Parameter
Type
Description
type
String
DB engine. Value:
- MySQL
- PostgreSQL
- SQLServer
version
String
Database version.
For details about supported database versions, see section Querying Version Information About a DB Engine.
Table 12 ha field data structure description Parameter
Type
Description
mode
String
Primary/standby instance type. The value is Ha.
replication_mode
String
Replication mode for the standby DB instance. This parameter is valid only when the instance is an HA instance.
Value:
- For RDS for MySQL, the value is async or semisync.
- For RDS for PostgreSQL, the value is async or sync.
- For RDS for 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 13 backupStrategy field data structure description Parameter
Type
Description
start_time
String
Backup time window. Automated backups will be triggered during the backup time window.
The value cannot be left blank. 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
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.
Table 14 volume field data structure description Parameter
Type
Description
type
String
Storage type.
Its value can be any of the following and is case-sensitive:
- ULTRAHIGH: ultra-high I/O
- CLOUDSSD: cloud SSD. This storage type is supported only with general-purpose and dedicated DB instances.
- ESSD: extreme SSD
size
Integer
Storage size.
Its value range is from 40 GB to 4,000 GB. The value must be a multiple of 10.
- Example normal response
RDS for MySQL single instance created.
{ "instance": { "id": "dsfae23fsfdsae3435in01", "name": "trove-instance-rep2", "datastore": { "type": "MySQL", "version": "5.7" }, "flavor_ref": "rds.mysql.s1.large", "volume": { "type": "ULTRAHIGH", "size": 100 }, "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" }RDS for MySQL primary/standby instance created.
{ "instance":{ "id": "dsfae23fsfdsae3435in01", "name": "trove-instance-rep2", "datastore": { "type": "MySQL", "version": "5.7" }, "ha": { "mode": "ha", "replication_mode": "semisync" }, "flavor_ref": "rds.mysql.s1.large.ha", "volume": { "type": "ULTRAHIGH", "size": 100 }, "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" }Read replica created for the RDS for MySQL instance.
{ "instance":{ "id": "dsfae23fsfdsae3435in01", "name": "trove-instance-rep2", "flavor_ref": "rds.mysql.s1.large.rr", "volume": { "type": "ULTRAHIGH", "size": 100 }, "region": "", "availability_zone": "", "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
- Abnormal
For details, see Status Codes.
Error Code
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot