Search code examples
ibm-cloud

Retrieve private service endpoints using the ibmcloud cli


Most services on the IBM Cloud catalog now support "private endpoints" as described at https://cloud.ibm.com/docs/account?topic=account-service-endpoints-overview

I'm writing some automation for our application and I'd like to obtain the private endpoint for my database from a simple bash script. I found that I can create a service key and invoke ibmcloud resource service-key (NAME | ID) to list the contents of that key (which includes the service's public endpoint). Unfortunately, I can't seem to find any command for listing the corresponding private endpoint.

In this particular case I am using the databases-for-postgresql service, but I was hoping for a general way to do this that will work across service types. I can get the private endpoint information from the UI, so I know the service instance has one.

If I can't get the private endpoint from an existing command, can I piggy-back on the cli's session to invoke a curl command without messing with IAM? For example, to invoke the curl command mentioned at the bottom of https://www.ibm.com/cloud/blog/introducing-private-service-endpoints-in-ibm-cloud-databases

curl -sS -XPOST "https://api.us-south.databases.cloud.ibm.com/v4/ibm/deployments/<deployment CRN/users/admin/connections/private" \
  -H "Authorization: Bearer <IBM API TOKEN>"

Solution

  • The IBM Cloud CLI Cloud Databases plug-in provides this capability. Details about the deployment-connections command can be found here: https://cloud.ibm.com/docs/databases-cli-plugin?topic=databases-cli-plugin-cdb-reference#connections

    The syntax is roughly: ibmcloud cdb deployment-connections [the-database] -e private

    If you have not already installed this plug-in, you can do so with this command: ibmcloud plugin install cdb