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| Key | Description |
|---|---|
type | Database type (for example rds-mysql, csql-postgres) |
keys[].secretKey | Which credential to read (username, password, hostname, …) |
keys[].envKey | The 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
- Application Dependencies — all dependency engines, and how to choose
- Attach to Your Application
- Secrets Manager
- IAM Service Accounts
- Access Management
Updated about 5 hours ago
Did this page help you?