Cloud Databases CLI

Gen 2

To interact with Cloud Databases on Gen 2 via the CLI you must utilize the IBM Cloud Resource Controller's CLI. For more info please see General IBM Cloud® CLI (ibmcloud) commands.

The Cloud Databases plugin supports only Gen 1 instances. For Gen 2 instances, use the Resource Controller CLI.

Getting started - Create an instance

You can create an instance by using the following command:

ibmcloud resource service-instance-create <INSTANCE_NAME> <SERVICE_NAME> <SERVICE_PLAN_NAME> <LOCATION> -g <RESOURCE_GROUP>

Example of full command for Databases for PostgreSQL:

ibmcloud resource service-instance-create <INSTANCE_NAME> <SERVICE_NAME> <SERVICE_PLAN_NAME> <LOCATION> -g <RESOURCE_GROUP>  -p '{
   "dataservices":{
      "postgresql": {
         "storage_gb": 10,
         "members": 2,
         "host_flavor": "b3c.8x32.encrypted",
         "version": "NUMBER"
      },
      "encryption": {
         "disk": "crn:v1..."
      },
      "$schema": {
         "version": "1.0.0"
      }
   }
}'

Example of full command for Databases for MongoDB:

ibmcloud resource service-instance-create <INSTANCE_NAME> <SERVICE_NAME> <SERVICE_PLAN_NAME> <LOCATION> -g <RESOURCE_GROUP> -p '{
   "dataservices":{
      "mongodb": {
         "storage_gb": 10,
         "host_flavor": "b3c.8x32.encrypted",
         "version": "NUMBER"
      },
      "encryption": {
         "disk": "crn:v1..."
      },
      "$schema": {
         "version": "1.0.0"
      }
   }
}'

Full command for Event Streams:

ibmcloud resource service-instance-create <INSTANCE_NAME> <SERVICE_NAME> <SERVICE_PLAN_NAME> <LOCATION> -g <RESOURCE_GROUP> -p '{
   "dataservices":{
      "kafka": {
        "throughput_mb_s": 1000,
        "storage_gb": 200
      },
      "encryption": {
         "disk": "crn:v1..."
      },
      "$schema": {
         "version": "1.0.0"
      }
   }
}'

Getting information about your instance

You can get instance information using the following command:

ibmcloud resource service-instance <INSTANCE_NAME> -o JSON

Update your instance

To update your instance (this includes operations, such as scaling and modifying other parts of your service), use the following command:

ibmcloud resource service-instance-update <INSTANCE_NAME> -p '<{FIELDS_TO_UPDATE}>'

Example of full updates for Databases for PostgreSQL:

ibmcloud resource service-instance-update <INSTANCE_NAME> -p'{
   "dataservices":{
      "postgresql": {
         "storage_gb": 10, <------ Change to the value you desire
         "members": 2, <------ Change to the value you desire
         "host_flavor": "b3c.8x32.encrypted" <------ Change to the value you desire
      },
   }
}'

Example of full updates for Databases for MongoDB:

ibmcloud resource service-instance-update <INSTANCE_NAME> -p'{
   "dataservices":{
      "mongodb": {
         "storage_gb": 10, <------ Change to the value you desire
         "host_flavor": "b3c.8x32.encrypted" <------ Change to the value you desire
      },
   }
}'

Example of full updates for Event Streams:

ibmcloud resource service-instance-update <INSTANCE_NAME> -p'{
   "dataservices":{
      "kafka": {
         "throughput_mb_s": 1000, <------ Change to the value you desire
         "storage_gb": 200 <------ Change to the value you desire
      },
   }
}'

Restore an Databases for PostgreSQL or Databases for MongoDB instance

ibmcloud resource service-instance-create <INSTANCE_NAME> <SERVICE_NAME> <SERVICE_PLAN_NAME> <LOCATION> -g <RESOURCE_GROUP>  -p '{
   "dataservices":{
      "restore_backup_id": "crn:v1...123-456-7890"
   }
}'

Create and list backups

This is currently not available via the CLI. To create or list a backup, use the UI.

Manage users

To create a user:

ibmcloud resource service-key-create NAME [ROLE_NAME] ( --instance-id SERVICE_INSTANCE_ID | --instance-name SERVICE_INSTANCE_NAME) [--service-id SERVICE_ID]

To delete a user:

ibmcloud resource service-key-delete ( NAME | ID ) [-g RESOURCE_GROUP]

Updating a user is not possible for Gen 2 instances.

Manage IP addresses (Allowlisting)

Cloud Databases utilizes context-based restrictions for its allowlisting needs. To manage your IP address via the CLI, see Context-based restrictions CLI plug-in.