• Relational Database Service

rds
  1. Help Center
  2. Relational Database Service
  3. API Reference
  4. API Calling
  5. Examples
  6. Creating a Single DB Instance (v1)

Creating a Single DB Instance (v1)

Flow Chart

Figure 1 Process of creating a DB instance

The overall process is as follows:

  1. Call List Datastore Version to obtain the database ID ($dbId) and database version ($version).
  2. Obtain the region. Define the variable as $region.

    For details about how to obtain this parameter value, see Regions and Endpoints.

  3. Call List Flavor to obtain the flavorRef ($flavorId). $dbId obtained in 1 and $region obtained in 2 are used in the request.
  4. Obtain the availabilityZone. Define the variable as $availabilityZone.

    For details about how to obtain this parameter value, see Regions and Endpoints.

  5. Call VPC to obtain the VPC ID ($vpc), subnet ID ($subnetId), and security group ID ($securityGroup.id).
  6. Call Create Database Instance to create a single DB instance. $region obtained in 2, $flavorId obtained in 3, $availabilityZone obtained in 4, $vpc, $subnetId, and $securityGroup.id obtained in 5 are used in the request body.

API Calling

  1. Obtain the database version information.
    curl -H "Content-Type: application/json" "X-Auth-Token: $X-Subject-Token" "X-Language: en-us"$SERVER_URL/v1/{project_id}/datastores/{datastore_name}/versions

    Example response:

    {
        "id": "e8a8b8cc-63f8-4fb5-8d4a-24c502317a61",
        "name": "5.6",
        "datastore": "abc8b8cc-63f8-4fb5-8d4a-24c502317a61",
        "image": "89932337-cde6-4d8f-847a-b76014ec6796",
        "packages": "MySQL-server-5.6",
        "active": 1
    }
  2. Obtain the region. Define region as $region.

    For details about how to obtain this parameter value, see Regions and Endpoints.

  3. Obtain flavorId.
    curl -H "Content-Type: application/json" "X-Auth-Token: $X-Subject-Token" "X-Language: en-us"$SERVER_URL/v1/{project_id}/flavors?dbId=$dbId&region=$region

    Example response:

    {
        "flavor": {
            "id": "f7f51f85-cfcd-4409-ae91-b3eae186d0ea",
            "name": "OTC_MYLM_XLARGE",
            "ram": 32768,
            "specCode": "rds.mysql.m1.xlarge"
        }
    }

    Define flavorId as $flavorId.

  4. Create a single DB instance.
    curl -X POST $SERVER_URL/v1/{project_id}/instances -H "Content-Type: application/json" "X-Auth-Token: $X-Subject-Token" "X-Language: en-us" -d '{"instance": {"name": "tenant-instance-123","datastore": {"type": "MySQL","version": "$version"},"flavorRef": " $flavorId","volume": {"type": "COMMON","size": 100},"region": " $region","availabilityZone": " $availabilityZone","vpc": "$vpc ","nics": {"subnetId": "$subnetid "},"securityGroup": {"id": "bb62ffb9-a37a-4821-92b9-f9e0712e389f"},"backupStrategy": {"startTime": "01:00:00","keepDay": 3} ,"dbRtPd": "Test@123"}}'

    Example response:

    {
        "instance": {
            "id": "b0468a4a-5790-4a4f-8442-9030e52369e6",
            "status": "BUILD",
            "name": "tenant-instance-123",
            "created": "",
            "hostname": "",
            "type": "master",
            "region": "eu-de",
            "updated": "",
            "availabilityZone": "eu-de-01",
            "vpc": "f7513b5d-5c48-4332-8f47-a3c29c2613e7",
            "nics": {
                "subnetId": "4a7d3555-6410-4338-8859-2be61d51662a"
            },
            "securityGroup": {
                "id": "bb62ffb9-a37a-4821-92b9-f9e0712e389f"
            },
            "flavor": {
                "id": "bf07a6d4-844a-4023-a776-fc5c5fb71fb4"
            },
            "volume": {
                "type": "ULTRAHIGH",
                "size": 100
            },
            "extendparam": {
                "jobs": [
                    {
                        "id": "8a3eb75e5577819f0155778220600001"
                    }
                ]
            },
            "backupStrategy": {
                "startTime": "01:00:00",
                "keepDays": 3
            }
        }
    }