Postgres workload credentials ΒΆ

When an Application or Job uses a Postgres database, Postgres provides connection settings as environment variables. Workloads authenticate with TLS client certificates; no password is provided.

Environment variables ΒΆ

Each credential set contains these variables:

VariableValue
PGHOSTDatabase hostname
PGPORTDatabase port
PGDATABASEDatabase name
PGUSERDatabase username
PGSSLMODETLS verification mode
PGSSLCERTPath to the workload's client certificate
PGSSLKEYPath to the workload's client key
PGSSLROOTCERTPath to the CA certificate

Roles and prefixes ΒΆ

The role controls which credential sets the workload receives:

RoleCredential prefixesIntended use
adminUnprefixed and READWRITE_Schema migrations and ordinary application traffic
readwriteREADWRITE_Ordinary application traffic
readREAD_Read-only application traffic

admin is the default role.

For example, a readwrite credential has variables such as READWRITE_PGHOST and READWRITE_PGDATABASE.

When you set envPrefix, it is prepended before the role prefix. With envPrefix: MYDB_, a readwrite credential has variables such as MYDB_READWRITE_PGHOST.

When envPrefix is not set, PostgreSQL clients that support standard PG* environment variables work out of the box with the unprefixed admin credentials. Use the READWRITE_ credentials for the long-running application process when the workload also runs schema migrations.