Skip to content

fleet-infra

Terraform for the fleet's cloud infrastructure. Status: draft, nothing applied, nothing pushed. Binding conventions: fleet IaC council verdict, 2026-10-29 (FLT-281 / FLT-312).

Language: stated deviation from C#-first

This repo is HCL (Terraform 1.17.1). The standing policy is C# first; the council approved the deviation because the mandate names Terraform and HCL is declarative config, not application code. C# owns the tooling around it. CDKTF and Pulumi .NET were rejected by the council.

Layout

modules/                 shared modules (empty on purpose; no provider-neutral wrappers)
stacks/
  shared/bootstrap/      state bucket, GitHub OIDC WIF, plan-only SA  (gcs, prefix shared/bootstrap)
  v4v/prod/              Verse4Verse prod: GCP imports + gated Cloudflare
  ww/  v4v/staging/ ...  not started
.github/workflows/plan.yml   plan-only on pull requests

One state per stack and env, in a versioned GCS bucket in the admin project. Backends are partial (backend "gcs" {}); values arrive only via -backend-config. Providers and Terraform are pinned exactly (= 1.17.1, google/google-beta 8.9.0, cloudflare 5.28.1); .terraform.lock.hcl is committed for linux, windows and macOS arm64.

Bootstrap order

  1. Andrew picks the admin project and creates it (open item).
  2. In stacks/shared/bootstrap: terraform init (local backend), then plan and apply with -var admin_project_id=<project> and -var 'plan_viewer_project_ids=["<admin>","verse4verse-prod"]'. This first apply is the only one done locally; the local state file is the only copy until moved.
  3. Move bootstrap state into the bucket it created (add a partial backend "gcs" {}, terraform init -migrate-state -backend-config=...), then delete the local state.
  4. Create repo variables from the outputs: TF_STATE_BUCKET, WIF_PROVIDER, PLAN_SERVICE_ACCOUNT.
  5. Open the first PR; CI plans stacks/v4v/prod.

Run a plan locally

cd stacks/v4v/prod
terraform init \
  -backend-config="bucket=<state bucket>" \
  -backend-config="prefix=v4v/prod"
terraform plan -lock-timeout=60s -detailed-exitcode

Exit 0 means no changes, which is the acceptance bar for the V4V import PR. Offline checks need no credentials: terraform init -backend=false, terraform fmt -check, terraform validate.

Apply flow

Never terraform apply from a laptop. After merge: build a fresh saved plan (plan -out=tfplan), a human approves that exact plan, and apply runs terraform apply tfplan and nothing else, serialized per stack (one apply at a time; the GCS lock backs this up). CI today is plan-only; the apply workflow, its environment approval and its separate apply service account are not built yet.

Import and secrets rules

import {} blocks only; -generate-config-out output is a draft to review, not to merge. Secret Manager gets containers and IAM only, never secret versions. The V4V Worker keeps public Cloud Run ingress and authenticates to the origin with a header.

Open items

  • Admin project: Andrew to choose; bootstrap has no default.
  • Cloudflare token (Workers + verse4verse.org zone scope): needed to read the zone id, Worker settings, custom domain ids and DNS records, then set manage_cloudflare = true.
  • Staging stack (stacks/v4v/staging) next, then WW in tiers.
  • Origin-header check in the app and Worker, the apply workflow, and the security-fix order (SSH/RDP, Cloud Armor, default-SA Editor role, public bucket) are tracked outside this repo.

Status

  • 2026-10-30: bootstrap applied to jones-gaffney-fleet-admin (26 resources). State migrated to gs://jones-gaffney-fleet-admin-tfstate/shared/bootstrap; plan -detailed-exitcode exits 0. Plan SA fleet-infra-plan@jones-gaffney-fleet-admin.iam.gserviceaccount.com; WIF provider projects/766382874322/locations/global/workloadIdentityPools/github-actions/providers/github-oidc.

  • 2026-10-30: stacks/v4v/prod imported (41 resources, 0 added/changed/destroyed). The next plan -detailed-exitcode exits 0, and verse4verse.org returned 200 with /health ok afterwards. Cloudflare stays gated off until a Workers + verse4verse.org-scoped token exists.