Charlie Roffe

Principal Architect & Engineering Director · Cloud & AI

Madrid, Spain · LinkedIn · GitHub

ADR-009: Runtime Configuration & Secrets Management

Context

Private keys, webhook endpoints, and API configurations must be secured. They must never be checked into Git or baked into public container images, and they must support instant rotation without code redeployments.

Decision

Utilize Google Cloud Secret Manager to store all runtime secrets, securely exposing them as environment variable mounts directly to the Cloud Run services at boot time.

Access is guarded by GCP project IAM service account bounds. The server resolves secret values dynamically from its local environment, targeting the "latest" revision.

Each environment has three secrets: cv-gate-<env> (CV_GATE_SECRET), turnstile-<env> (TURNSTILE_SECRET) and resend-<env> (RESEND_API_KEY), each stored only in europe-southwest1 (Madrid). Terraform creates them with a placeholder version and the real values are added out-of-band. Google APIs (Vertex AI, Firestore) need no stored key: they use Application Default Credentials.

Consequences

Benefits:
* Complete isolation: no passwords exist in source files or docker layers.
* Secrets are instantly rotatable in Secret Manager without rebuilds; the next container spin-up immediately resolves the new value.
* Strictly auditable access history in GCP logs.

Alternatives considered

1. Hardcoding secrets in .env files (pushed to repository): Strongly rejected as a critical security violation.
2. Baking secrets into Docker images during build time: Rejected as it exposes secrets to anyone with registry read access.

Amended (2026-10-16): one documented exception. GOOGLE_APPS_SCRIPT_URL (the CV request gateway) comes from a GitHub Actions secret, reaches Terraform as TF_VAR_google_apps_script_url and is set on Cloud Run as a plain environment variable. It is an endpoint address rather than the credential: requests to it carry CV_GATE_SECRET, which stays in Secret Manager.

Amended (2026-10-31): service-account keys and basic roles. An audit found keys that never expire and an owner role on an outside connector's account, a default compute account with editor, and unused accounts left over from AI Studio. From now on: nothing this repository deploys or runs uses a service-account key; outside tools federate where they can, otherwise get one read-only key that expires within 90 days and is listed in a register; no service account holds a basic role; and Terraform grants IAM additively (google_project_iam_member), never through authoritative policy or binding resources. Organization policies would enforce this, but the project has no organization, so the register and a re-run of the audit are the controls. The clean-up steps are in docs/service-account-cleanup.md.

Architecture Decision Records