Skip to content

GCP

Project development-485000 (number 287267207777) runs no compute. It holds Secret Manager, the Terraform state bucket, the fastlane match bucket, Google OAuth clients, the Places API key, FCM and Play publishing identities, and the Workload Identity Federation pool that Terraform CI signs in through.

Terraform: infrastructure/gcp/, state in gs://tomoda-tfstate under gcp/state. PRs get a CI plan; merging to main applies it. See Terraform CI/CD.

Managed by Terraform

Resource File Notes
Secret Manager secrets (containers) secrets.tf One list, automatic replication, prevent_destroy. No versions: values never enter state
Service accounts terraform-ci, terraform-apply, tomoda-release, eso-reader, firebase-adminsdk-tomoda, play-publisher service_accounts.tf Keys are created by hand (below)
Project roles for those SAs service_accounts.tf Additive google_project_iam_member; Google-agent bindings are not touched
Human project roles and native-release secret access (user:…@tomoda.life) people.tf Additive; the single roles/owner grant has prevent_destroy. See People and access
WIF pool github-actions, provider github-oidc, terraform-ci and terraform-apply impersonation wif.tf Accepts only assertion.repository == 'tomoda-labs/devops'; terraform-apply only from terraform-apply.yml on main
WIF pool github-actions-tomoda, provider github-oidc, tomoda-release impersonation wif.tf Accepts only tomoda-labs/tomoda on refs/heads/main; tomoda-release only from the release workflows (IAM)
tomoda-ios-certs bucket storage.tf fastlane match store, public access prevented. prevent_destroy
tomoda-ios-signing bucket storage.tf fastlane match store in northamerica-northeast1, public access prevented. prevent_destroy
Enabled APIs the project still uses services.tf disable_on_destroy = false
Places API key tomoda-google-places-api apikeys.tf Restricted to places.googleapis.com and places-backend.googleapis.com

Manual, and why

Item Why it stays manual
Secret values Kept out of git and Terraform state. Set with gcloud secrets versions add or scripts/setup-gcp-secrets.sh
Service account keys (eso-reader, play-publisher) A key in Terraform lands in state. Each is created once and stored where its consumer reads it
OAuth consent screen and OAuth clients Google shut down the IAP OAuth Admin API; consumer OAuth clients have no Terraform resource. See OAuth clients
Firebase project settings and FCM Console-managed. Terraform owns only the firebase-adminsdk-tomoda SA, its roles/firebase.admin grant and the APIs
Play Console access for play-publisher Granted in Play Console, not GCP IAM
Places quota caps Quota preferences set in the Console; see Cost monitoring. Budgets and org IAM are in GCP organization

Service accounts

SA Used by Key
terraform-ci Terraform plan in this repo on any branch, through WIF; read-only (see IAM) None
terraform-apply Terraform apply from terraform-apply.yml on main, through WIF None
tomoda-release Release workflows on main in both repos, through WIF; reads the release App key and prod OTA upload key None
eso-reader External Secrets in the cluster (roles/secretmanager.secretAccessor) external-secrets/gcpsm-credentials, created by scripts/ovh/bootstrap-argocd.sh
firebase-adminsdk-tomoda Firebase Admin SDK (push) Google-managed keys only
play-publisher Play uploads (fastlane supply) JSON in tomoda-play-service-account

Rotate any key by creating a new one, updating its consumer, then deleting the old key. Rotation for eso-reader is in IAM.

People and access

Access to the project comes from two levels:

Level Managed Where
Org 650647255726 (tomoda.life) Terraform, applied locally by an org owner; gcp-* group membership in Google Workspace admin infrastructure/gcp-org/, see GCP organization
Project development-485000 Terraform infrastructure/gcp/people.tf

Org-level roles are inherited by every project in the org, so project roles are only the real limit for someone with no project-power role at the org. Only org owners have one; see GCP organization → Access model.

In people.tf:

  • local.people maps each @tomoda.life login to its project roles. The owner grant is a separate resource that a PR cannot remove.
  • local.native_releasers lists who runs native store releases locally with fastlane; each gets roles/secretmanager.secretAccessor on just the secrets in local.native_release_secrets and roles/storage.legacyBucketReader plus roles/storage.objectViewer on tomoda-ios-certs (the fastlane match store). Read access to that bucket comes only from this list; beyond it, only project owners and terraform-apply can reach it.

Change access by editing those lists and opening a PR; merge applies it:

  • Onboard: add the login to local.people with roles/viewer as the baseline plus only the roles their work needs (and to local.native_releasers if they ship native builds).
  • Change roles: edit the person's list. Removing a role destroys that one grant on merge.
  • Offboard: delete the person's entries; merge removes every grant listed for them. Remove them from local.org_members in infrastructure/gcp-org/ (see GCP organization) and from gcp-* groups in Workspace admin, then run the audit query.

Grant project roles through this file, not the Console: a hand-made grant is invisible to Terraform and survives offboarding. A grant found outside this file is revoked once with gcloud projects remove-iam-policy-binding and not added to config.

Adding a secret

  1. Add the name to local.secrets in infrastructure/gcp/secrets.tf and open a PR. Merge applies it.
  2. Set the value without it touching shell history: paste it on stdin and end with Ctrl-D, or pipe the clipboard.

    gcloud secrets versions add <name> --project=development-485000 --data-file=-   # paste, then Ctrl-D
    pbpaste | gcloud secrets versions add <name> --project=development-485000 --data-file=-
    

    For binary or multi-line files (keystores, .p8 keys), pass the file, then delete it:

    gcloud secrets versions add <name> --project=development-485000 --data-file=./key.p8 && rm -P ./key.p8
    
  3. Add it to the inventory in Secrets management and reference it from an ExternalSecret or workflow.

Removing a secret

prevent_destroy covers every instance of google_secret_manager_secret.this, so a secret is retired through the unprotected retired resource instead:

  1. Remove its consumers (ExternalSecrets, workflows, scripts/setup-gcp-secrets.sh) and the inventory row.
  2. In infrastructure/gcp/secrets.tf, remove the name from local.secrets and add a moved block from google_secret_manager_secret.this["<name>"] to google_secret_manager_secret.retired["<name>"]. The plan shows the move and one destroy.
  3. Merge. Apply-on-merge deletes the secret and all its versions.
  4. Once applied, delete the moved blocks in a later PR.

OAuth clients

The consent screen (one per project) and every OAuth client are created in APIs & Services → Credentials. IDs and secrets go to Secret Manager (tomoda-google-client-id, -client-secret, -ios-client-id, -android-client-id). The click path for a new web client is in Secrets management.

The web client 287267207777-7d0cdo9ueh4ir6jd90ge411crcmfvs92 is shared by three consumers: the mobile app, oauth2-proxy (Grafana, pgAdmin, redis-insight) and Argo CD Dex (k8s/envs/platform/argocd/values.yaml). The iOS and Android clients are app-only.

Admin access does not depend on the consent screen's Internal/External setting. Each admin surface enforces tomoda.life itself:

Surface Domain gate Where
Argo CD (Dex) hostedDomains: ["tomoda.life"] + RBAC allow-list k8s/envs/platform/argocd/values.yaml
Grafana, pgAdmin, redis-insight oauth2-proxy --email-domain=tomoda.life k8s/envs/platform/oauth2-proxy/application.yaml

To let any Google account sign in to the app, switch the consent screen from Internal to External and publish it (Console only). No client IDs change and the admin gates above still hold. Give oauth2-proxy and Dex their own web client afterwards so an app-client incident cannot take down admin sign-in: create it with both admin redirect URIs (https://argo-app.tomoda.life/api/dex/callback, https://auth.tomoda.life/oauth2/callback), store it under new secret names, and point the platform ExternalSecrets and the Dex clientID at it.

Places API

The backend reads tomoda-google-places-api-key, a copy of the key string from google_apikeys_key.places. After rotating the key in the Console, update that secret. Per-day quota caps and the billing budget are set in the Console; see Cost monitoring.

Bootstrap

From an empty project, as a project owner:

  1. Create the state bucket (it holds this stack's own state):

    gcloud storage buckets create gs://tomoda-tfstate \
      --project=development-485000 --location=northamerica-northeast1 --uniform-bucket-level-access
    gcloud storage buckets update gs://tomoda-tfstate --versioning
    gcloud services enable apikeys.googleapis.com --project=development-485000
    
  2. Run the first apply locally with your own credentials (terraform init && terraform apply in infrastructure/gcp/). This creates the WIF pool and both CI service accounts with their roles.

  3. Set the repo variables GCP_WIF_PROVIDER, GCP_TERRAFORM_CI_SA and GCP_TERRAFORM_APPLY_SA from terraform output. CI plans from then on.
  4. Create the SA keys above, then fill secret values (Bootstrap).

terraform-apply holds roles/resourcemanager.projectIamAdmin, so later role changes for either CI identity apply through CI without a manual grant.