Inject Database Credentials

This guide shows you how to give an application its database connection details automatically, using the db dependency engine.

Connects your application to a database Component provisioned on the platform.
This is the same mechanism described in
Attach to Your Application.

dependency:
  db:
    type: rds-mysql
    keys:
      - secretKey: username
        envKey: MYSQL_USERNAME
      - secretKey: password
        envKey: MYSQL_PASSWORD
      - secretKey: hostname
        envKey: HOSTNAME
KeyDescription
typeDatabase type (for example rds-mysql, csql-postgres)
keys[].secretKeyWhich credential to read (username, password, hostname, …)
keys[].envKeyThe environment variable name your application reads
keys[].namespace(optional) read a database that lives in another namespace
keys[].user(optional) read credentials for a different database user
keys[].instance(optional) read credentials for a different database instance

The three optional overrides exist for the shared-database case: a reporting
application in its own namespace can read the credentials of a database that
belongs to another namespace, without that database being duplicated.

Related articles


Did this page help you?