Environment Variables
| Variable | Required | Notes |
|---|---|---|
SECRETS_MANAGER_TYPE | Yes | Set to gcp_secret_manager. |
SECRETS_MANAGER_GCP_PROJECT_ID | Yes | GCP project that owns the secrets. |
SECRETS_MANAGER_GCP_CREDENTIALS_JSON | Optional | Raw JSON service account key. |
SECRETS_MANAGER_GCP_CREDENTIALS_FILE | Optional | Path to service account JSON file. |
- If
SECRETS_MANAGER_GCP_CREDENTIALS_JSONis set, it is used. - Else if
SECRETS_MANAGER_GCP_CREDENTIALS_FILEis set, it is used. - Otherwise, default Google credentials are used.
Create GCP Resources and Credentials
- Select or create a GCP project.
- Enable Secret Manager API:
- Google Cloud Console -> APIs & Services -> Library -> Secret Manager API -> Enable.
- Create a service account:
- IAM & Admin -> Service Accounts -> Create service account.
- Grant permissions:
- For quick setup:
roles/secretmanager.admin. - For least privilege: allow access/create/version-add/delete secret operations.
- For quick setup:
- Create a service account key:
- Service account -> Keys -> Add key -> Create new key -> JSON.
- Download the JSON key file.
Map Credentials to Env Vars
| GCP value | Env var |
|---|---|
| Project ID | SECRETS_MANAGER_GCP_PROJECT_ID |
| JSON key file path | SECRETS_MANAGER_GCP_CREDENTIALS_FILE |
| JSON key content | SECRETS_MANAGER_GCP_CREDENTIALS_JSON |
SECRETS_MANAGER_GCP_CREDENTIALS_FILE or SECRETS_MANAGER_GCP_CREDENTIALS_JSON.
Local Switch Example
wonderful-secrets after changing these values.
What to Verify
- Run the smoke test from Secret Managers.
- Confirm secrets appear in Google Secret Manager under the configured project.