Skip to content

Instantly share code, notes, and snippets.

View mpereira-dev's full-sized avatar

Miguel Pereira mpereira-dev

  • Independent
  • 0.0.0.0
View GitHub Profile
@mpereira-dev
mpereira-dev / getDBCredentials.sh
Last active August 17, 2020 23:30
Extract PostgreSQL Credentials for a Pivotal Cloud Foundry App
# * Extract PostgreSQL credentials from a bound service for use in this PCF app.
# ! Your manfiest file must bind the app to an existing PostgreSQL service via 'services'.
# @env VCAP_SERVICES - The Cloud Foundry services this app is bound to. This is set automatically for you.
# @env POSTGRES_SERVICE - The name of the specific PostgreSQL service to use. This is useful if your app is bound to multiple services.
# @env POSTGRES_SERVICE_KEY - The PostgreSQL service vendor key. Defaults to aws-rds-postgres for AWS.
# ? Reference: https://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#VCAP-SERVICES
function getDBCredentials {
echo "[INFO] Extracting DB credentials from VCAP_SERVICES...";
# Assume it is an AWS RDS PostgreSQL service if not specified.