Secrets in Vault or Secret Manager

If your operations team manages credentials and access in Vault, AWS Secrets Manager, Google Secret Manager or Azure Key Vault, services on Kubernetes, VMs and ECS can use that store.

If a secret was exposed

  1. Revoke the exposed credential immediately and issue a replacement.
  2. Register the replacement in the central store. Retrieve it by name, path or reference key, and remove the old value from code and configuration.
  3. Grant read access only to the service accounts that need it. Verify that services use the replacement successfully and that the old credential is rejected.

Recommended approach

  • At startup, retrieve values with an SDK, sidecar, CSI driver or init container. With Google Cloud Secret Manager, prefer direct API access or an official integration when available.
  • Consider dynamic credentials or short-lived tokens if your store supports them. When registering a secret, set the rotation interval, access policy and audit logs to review.

Examples

Before

python
API_KEY = "sk-prod-123456"
DB_PASSWORD = "super-secret-password"

After

python
import os

API_KEY = os.getenv("API_KEY")
DB_PASSWORD = os.getenv("DB_PASSWORD")

The example reads API_KEY and DB_PASSWORD from environment variables populated by the secret store. It makes no store API call. Validate required values and stop startup if one is missing.

Additional checks

Check that application errors keep secret values out of logs. If a deployment requires a pinned version, verify that the application does not always select latest.