Pivotal Knowledge Base

Follow

Locating Service Credentials for a Bound Service

Environment

This tutorial is applicable for Pivotal Cloud Foundry versions 1.0.0 - 1.2.x.

Purpose

This article demonstrates how to locate the credentials and connection information for a service instance that is bound to an application running on Pivotal Cloud Foundry®. This is useful if you need to connect directly to the service in question.

Resolution

There are three options to retrieve the connection information.

Web Browser & Developer Console

  1. Access the Console application in your browser.  
  2. Select the organization and space where your service is deployed.  
  3. Under the Services section, locate the service itself.  
  4. Click the Manage link next to the service.  The service provider should then display your credentials.

Terminal & CF CLI - Option #1

  1. Open a terminal.
  2. Login with cf, select your organization and space.
  3. Run cf files <app_name> logs/env.log
  4. The output will show the environment variables accessible to your application which includes the service's credentials. In particular check the VCAP_SERVICES environment variable.

NOTE: This option will not work when the application has been stopped or has failed to stage.

Terminal & CF CLI - Option #2

  1. Open a terminal.
  2. Login with cf, select your organization and space.
  3. Run cf curl /v2/apps
  4. This will output a JSON blob. Locate resources → <app_name> → service_bindings_url
  5. Run cf curl <service_bindings_url>
  6. This will output a JSON blob for each bound service that includes the credentials.

Impact / Risks

Please use caution when displaying the credentials from your services.  The information will be shown in plain text. 

Comments

Powered by Zendesk