Skip to content

Validate OpenTofu as GCP foundation IaC without taking over Cloud Run releases #9842

Closed

Description

@Git-on-my-level

The public-browser deploy work around #9820 now has a JIT release contract; the remaining question needs validation against the real GCP project before any IaC migration. Evaluate OpenTofu as the owner of durable foundation only—GitHub OIDC/WIF, CI and runtime service identities, IAM, Secret Manager containers/accessor grants, and a versioned/locked GCS state bucket—while the centralized GitHub release action remains the sole writer of Cloud Run images, templates, secret references, revisions/tags, and traffic. On a GCP-authenticated machine, inventory the actual service identities and effective Secret Accessor grants, prove one development WIF + read-only plan pilot, identify the state-bucket bootstrap path, and record the chosen ownership boundary and staged migration plan. Do not place secret payloads or secret versions in state, and do not apply/import production resources as part of this investigation. Related: #6800 tracks the broader removal of long-lived Google credentials; this issue is specifically the OpenTofu foundation decision and live-GCP grounding.

Activity

  1. Git-on-my-level commented on Jul 15, 2026

    @Git-on-my-level
    MemberAuthor

    Coordination plan: no-mutation OpenTofu foundation slice

    Status: implementation in progress. This investigation and its first PR make no GCP changes, create no state bucket, import no resources, and do not alter any release workflow.

    This PR's contract

    • Add an OpenTofu foundation module with an intentionally empty resource graph and a GCS-backend shape that is initialized only with -backend=false.
    • Add separate development/production backend configuration examples. They contain placeholders only; no real bucket, project, identity, or secret metadata.
    • Add a source and generated-plan guard that permits only future foundation families: service accounts, narrowly additive IAM members, GitHub WIF pools/providers, Secret Manager containers/accessor IAM, and state-bucket metadata/IAM.
    • Reject Cloud Run, GKE workload, image/Artifact Registry, traffic/revision/template, arbitrary non-foundation resources, all data sources, and Secret Manager secret versions/payload attributes.
    • Add a credentials-free GitHub Actions validation workflow: tofu init -backend=false, tofu validate, a -refresh=false empty plan, and plan JSON inspection. It has contents: read only—no environment, id-token, GCP credentials, remote backend, or apply path.
    • Wire the static checker into the repo's deterministic check manifest so make preflight catches violations locally.

    Explicitly deferred manual follow-up

    1. Provision a separate, least-privilege audit identity with sufficient read-only visibility to inventory service accounts, project/secret IAM, WIF pools/providers, and GCS bucket metadata in both projects. The current read-only bots can inspect Cloud Run/GKE but are denied those IAM/Secret Manager/Storage APIs.
    2. Review and perform a one-time bootstrap for isolated, versioned state buckets and scoped state-reader/writer access. Record the bucket names outside source control; do not place secret payloads in state.
    3. Create a development-only GitHub WIF provider and separate plan/apply service accounts, constrained to this repository and protected environment/ref conditions.
    4. Run the first authenticated development read-only plan. Do not import or apply production resources.
    5. Migrate one low-risk workflow/runtime identity at a time under Security: Replace long-lived google-credentials.json service-account keys with keyless authentication (Workload Identity / ADC) #6800, with release workflows remaining the sole Cloud Run template/revision/traffic writers and verifying the expected runtime identity post-deploy.
    6. Only after service-level migration and evidence, rotate/delete long-lived JSON keys and consider production foundation changes.

    Decision record: OpenTofu may own durable identities, grants, secret metadata, and state only. GitHub release workflows remain the only Cloud Run/GKE release writers. The runtime service-account attachment is a release-workflow contract, not an OpenTofu-written Cloud Run template.

  2. Git-on-my-level commented on Jul 15, 2026

    @Git-on-my-level
    MemberAuthor

    No-mutation foundation slice complete

    Implemented locally in commit 9b7518d1d8 on codex/opentofu-foundation-safety. Nothing was pushed and no GCP resource, state bucket, IAM binding, WIF provider, secret, workflow environment, or release surface was changed.

    What is now checked in

    • An intentionally empty foundation module at infrastructure/opentofu/foundation with the GCS-backend shape and a locked hashicorp/google provider.
    • Development/production backend configuration examples only, containing placeholders rather than real bucket or project metadata.
    • A source/plan boundary checker plus fixtures. It permits only the agreed future foundation families and rejects Cloud Run, GKE, Artifact Registry, all data sources, Secret Manager versions/payload attributes, and arbitrary resource types.
    • A credentials-free validation workflow with contents: read only. The checker fails if that workflow gains GCP auth, an OIDC token, gcloud, or tofu apply.
    • The repository check manifest invokes the boundary checker locally and in CI.

    Verification evidence

    • Checksum-verified OpenTofu 1.12.4 downloaded locally.
    • Source: tofu init -backend=false and tofu validate passed with Google credential variables unset.
    • Empty plan: the checker generates a temporary copy without the GCS backend, then tofu init -backend=false, validate, and plan -refresh=false -lock=false passed with No changes; plan JSON inspection passed.
    • actionlint passed for the new workflow.
    • make preflight passed with all nine changed files selected, including the new boundary checker and its fixture suite.

    A GCS backend cannot produce a plan after init -backend=false, so the backend-free temporary copy is intentional: it proves the module/plan graph remains inert without ever configuring remote state. It does not claim to validate live GCS state access, WIF conditions, IAM grants, or effective Secret Accessor permissions.

    Next gate

    Keep the scope as written: this is a useful direction for durable identity/IAM/state ownership, but the next step is an explicitly approved development-only state/WIF bootstrap and read-only authenticated plan. Do not import/apply production resources or let OpenTofu write Cloud Run/GKE release surfaces.

  3. Git-on-my-level commented on Jul 15, 2026

    @Git-on-my-level
    MemberAuthor

    Scaffold PR is open: #9846

    The dev-pilot PR is intentionally gated on this landing first. A separate upstream PR cannot cleanly depend on an unmerged fork branch, and opening a stacked/duplicated PR now would weaken review rather than accelerate the pilot. After #9846 merges, the pilot branch will start from updated main and contain exactly one development WIF/read-only-plan identity change.

    The remaining non-code prerequisites are unchanged: approved dev audit visibility and the one-time state-backend bootstrap. They are required to choose real least-privilege grants and validate a live plan; no identifiers or IAM role set will be guessed into a PR.

  4. Git-on-my-level commented on Jul 15, 2026

    @Git-on-my-level
    MemberAuthor

    Development WIF pilot follow-up (after scaffold merge)

    The no-mutation scaffold is merged in c75abf5c63 / #9846. The code-only development pilot is now PR #9848. It has not changed GCP.

    What #9848 proves before any cloud mutation

    • The bootstrap plan is exactly five creates: dedicated development WIF pool/provider, plan service account, WIF impersonation binding, and project-level roles/browser.
    • The pilot is hard-locked to based-hardware-dev (1031333818730) and BasedHardware/omi main; it has no Cloud Run/GKE/release/secret-value path, tofu apply, remote backend, or long-lived credential path.
    • A live read-only dev-profile plan successfully read based-hardware-dev through google_project and proposed no infrastructure change. This validates the probe mechanics, not the not-yet-created WIF identity.

    Manual work only after #9848 is merged and separately approved

    1. A development operator creates an isolated versioned GCS state bucket with uniform bucket-level access. Keep its name/config outside source control and do not reuse a production bucket.
    2. Using a write-capable development-only operator identity, initialize pilots/development-wif-plan with that backend, review a saved plan, and apply that exact saved plan. Do not import existing WIF resources or broaden the five-resource diff.
    3. Perform metadata-only read-back of the WIF provider, service account, WIF binding, and roles/browser binding. Do not read Secret Manager payloads.
    4. Dispatch OpenTofu Development WIF Pilot from main; record its URL and the metadata-only read-back here. Success is GitHub OIDC exchange plus the google_project read. Failure must be fixed in development; do not bypass it with a key or a broader role.
    5. Keep production, Cloud Run/GKE deployment ownership, resource imports, and any stateful managed-resource migration out of scope. A later slice needs a fresh PR and the same dev-first proof.

    Decision gate

    If the manual bootstrap and dispatched WIF proof succeed, OpenTofu is useful as a narrow, incremental foundation control plane. It does not authorize managing runtime deploys or expanding permissions automatically.

  5. Git-on-my-level commented on Jul 15, 2026

    @Git-on-my-level
    MemberAuthor

    Development WIF pilot merged

    PR #9848 merged as 489870ab08c. It still makes no GCP mutation.

    The merged pilot now hard-locks the five-resource dev bootstrap to the immutable Omi GitHub repository/owner IDs, its dedicated main workflow, and the development environment. Its offline CI saves the plan, renders JSON, and accepts exactly the five approved create actions; extra OpenTofu configuration files, providers, modules, provisioners, resources, or actions fail the guard.

    Verification completed before merge: local 15-check preflight and pre-push gate; OpenTofu development-pilot and foundation GitHub validations; Desktop Swift build/release compile. The Repo Checks checkout job stalled twice in GitHub Actions; after the user explicitly authorized merging, the PR was merged through the administrator regular-merge path rather than treating that runner issue as a code pass.

    Remaining manual gate (unchanged)

    A separately approved development operator must create the isolated versioned state bucket, apply the saved five-resource bootstrap with a write-capable development-only identity, perform metadata-only read-back, then dispatch OpenTofu Development WIF Pilot from main and record its URL/result here. Do not create a write-capable GitHub identity, touch production, import resources, or change Cloud Run/GKE release ownership.

  6. Git-on-my-level commented on Jul 16, 2026

    @Git-on-my-level
    MemberAuthor

    Development-only OpenTofu proof stopped on a partial apply; based-hardware/production were not targeted or changed.

    • The reviewed saved plan passed the repository guard with exactly these five creates: google_service_account.plan, google_iam_workload_identity_pool.github, google_iam_workload_identity_pool_provider.github, google_service_account_iam_member.github_plan_impersonation, and google_project_iam_member.plan_project_browser.
    • Apply created only google_service_account.plan and google_project_iam_member.plan_project_browser (roles/browser); it then failed creating the WIF pool because GCP rejects its configured display name as longer than 32 characters. Per the stop rule: no retry, delete, import/adoption, permission expansion, provider, WIF binding, or workflow dispatch was performed.
    • State-governance record (not in source control; backend HCL also remains uncommitted): ~/.hermes/projects/2026-07-omi-9842-development-opentofu-pilot/state-governance.md. The development bucket has UBA/PAP/versioning, 7-day soft-delete recovery, no retention lock, project-Owner-only bucket compatibility bindings, and no GitHub/state-bucket grant.
    • Metadata read-back: plan SA exists; its only project grant is roles/browser; it has no WIF principal binding; WIF pool/provider are absent. Remote state records only the two partial resources. No broader pilot resources were created.
    • Workflow: not dispatched (there is no workflow URL or successful probe) because the bootstrap is incomplete.

    Blocker / required next step: repair the pool display-name validation in a separately reviewed source PR, then obtain a new explicit recovery/apply decision for this partial state. Only after a clean successful bootstrap and WIF probe may the next permitted work be one small development migration removing one real JSON-key path. Any future write-capable WIF work remains gated on required reviewers for the existing GitHub development environment.

  7. undivisible commented on Jul 20, 2026

    @undivisible
    Collaborator

    Closed: fix committed to main. See commit reference in previous audit. Stale-open — resolution confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions