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.peoplemaps each@tomoda.lifelogin to its project roles. The owner grant is a separate resource that a PR cannot remove.local.native_releaserslists who runs native store releases locally with fastlane; each getsroles/secretmanager.secretAccessoron just the secrets inlocal.native_release_secretsandroles/storage.legacyBucketReaderplusroles/storage.objectViewerontomoda-ios-certs(the fastlane match store). Read access to that bucket comes only from this list; beyond it, only project owners andterraform-applycan reach it.
Change access by editing those lists and opening a PR; merge applies it:
- Onboard: add the login to
local.peoplewithroles/vieweras the baseline plus only the roles their work needs (and tolocal.native_releasersif 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_membersininfrastructure/gcp-org/(see GCP organization) and fromgcp-*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¶
- Add the name to
local.secretsininfrastructure/gcp/secrets.tfand open a PR. Merge applies it. -
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,
.p8keys), pass the file, then delete it:gcloud secrets versions add <name> --project=development-485000 --data-file=./key.p8 && rm -P ./key.p8 -
Add it to the inventory in Secrets management and reference it from an
ExternalSecretor 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:
- Remove its consumers (
ExternalSecrets, workflows,scripts/setup-gcp-secrets.sh) and the inventory row. - In
infrastructure/gcp/secrets.tf, remove the name fromlocal.secretsand add amovedblock fromgoogle_secret_manager_secret.this["<name>"]togoogle_secret_manager_secret.retired["<name>"]. The plan shows the move and one destroy. - Merge. Apply-on-merge deletes the secret and all its versions.
- Once applied, delete the
movedblocks 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:
-
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 -
Run the first apply locally with your own credentials (
terraform init && terraform applyininfrastructure/gcp/). This creates the WIF pool and both CI service accounts with their roles. - Set the repo variables
GCP_WIF_PROVIDER,GCP_TERRAFORM_CI_SAandGCP_TERRAFORM_APPLY_SAfromterraform output. CI plans from then on. - 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.