A database in the cloud is a wonderful thing. It can serve as a secure, reliable and (most important) off-site data store for your application. It can also come in handy under different testing scenarios: for example, when you need to test an application refactor but can’t be bothered to spin up a database container locally, or when you’re trying to benchmark application performance under heavy load.

A good example of a cloud-native database is IBM Cloudant. IBM Cloudant is a fully-managed, distributed database that runs as a service on IBM Cloud. It is based on Apache CouchDB (although it is not open source itself) and stores documents using standard JSON. It can be accessed using a standard HTTP REST API.

With the IBM Cloud CLI, launching a new IBM Cloudant service is a simple two-step process:

  1. Create the service instance (read more about service instance creation). You can choose the authentication method for the instance; IAM is preferred over legacy credentials.

    ibmcloud resource service-instance-create mycloudant cloudant lite eu-de -p '{"legacyCredentials": false}'
    
  2. Create a service key associated with that service instance (read more about service credential creation). Make sure that you assign the Manager role to the key so that you can write to the database:

    ibmcloud resource service-key-create mycloudant-key Manager --instance-name mycloudant
    

    The response to the above request contains two important fields: apikey and host. Note these values, as you will need them to read and write data to the database.

Once instantiated, the IBM Cloudant service becomes visible in the IBM Cloud dashboard:

alt

You can now proceed to interact with the IBM Cloudant database using any of the following methods: