Developing software in the Real World

CLI credentials for a Cloud Foundry database

If you need access to your Cloud Foundry database from the command line the easiest way to get a set of credentials is to create a service key.

This is done using the command cf create-service-key {service-name} {key-name}. You can call the key anything, so to connect to my database that I created previously:

Now that we’ve set up the key, we can get the information using cf service-key {service-name} {key-name}:

The format is: postgres://{user}:{password}@{host name}:{port}/{database}, so you can quite easily extract the details for use with the command line PostgreSQL client.

When you no longer need it, you can delete the key using cf delete-service-key -f {service-name} {key-name}:

Mapping to the bx CLI tool

IBM’s CloudFoundry instance has its own CLI tool called bx. You can do all the same things, but the commands are different. This is the mapping:

cf command bx command
cf create-service-key bx service key-create
cf service-key bx service key-show
cf delete-service-key bx service key-delete

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *