Skip to content

separate plan and apply cloud identities, with the OIDC trade done before head code runs #4296

Closed

Description

@lex00

Wave 2, size L (3 clouds by 3 forges).

terragucci maps root globs to separate plan and apply identities and trades the OIDC token before the head is checked out (roles.ts, oidc-trade.ts; groups.ts runs one apply job per identity). The trade uses terragucci's own S3 and GCS clients (oidc-trade.ts:30-31). The env vars it sets (AWS_ROLE_ARN, the GCP external_account file, ARM_CLIENT_ID) are cloud SDK conventions, not Terraform ones.

chant today: the PR plan and apply jobs have no id-token, and share env and beforeScript (github generate-pipeline.ts:270-297). Plan and apply differ only in git write scope.

Design: an identity.cloud block mapping environment or member globs to {plan, apply} per cloud. The forge generators emit id-token and a trade step that runs before head checkout, and split apply jobs by identity.

Risk: leaking a token to head code. Should land before anything applies unattended (the policy and pre-merge apply issues).

terragucci then deletes roles.ts, oidc-trade.ts and groups.ts, and keeps Terragrunt's credentials as an input.

terragucci paths are under packages/terragucci/src at INTENTIUS/terragucci e6cb431. chant paths are at origin/main.

Part of #4287.

Activity

  1. added
    enhancement
    area:ci
    terragucci-lift
    on Oct 22, 2026
  2. lex00 commented on Oct 22, 2026

    @lex00
    ContributorAuthor

    Merged in #4316 (01e5f7c).

    ci.identity.cloud gives each cloud (aws, gcp, azure) a plan and an apply identity per environment and member globs. The plan job trades the job's OIDC token for the plan identity in a step before the checkout, run with node -e from /. Every later plan step drops the token request variables, so head code never sees a way to get the apply identity. Apply jobs take the apply identity. A rule that plans as an identity some rule applies as is refused (packages/core/src/workspace/declaration.ts:1237).

    Emulator proof tests for GitHub, GitLab and Forgejo run the generated plan job step by step and check that each step after the trade gets only plan credentials (lexicons/github/src/components/generate-pr-pipeline.identity.test.ts, and the gitlab and forgejo files of the same name).

    Docs: guide/security-cloud-identities.mdx and the Cloud identities section of reference/workspace-declaration.mdx.

    Deferred:

    • The plan job still holds CHANT_RUNNER_KEY.
    • chant ci run and chant ci serve do no OIDC trade.
    • A GitHub fork pull request gets no OIDC token, so its plan fails at the trade.
    • The Forgejo trade assumes the ACTIONS_ID_TOKEN_REQUEST_* variables. No real Forgejo runner has checked this yet.
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

    area:cienhancementterragucci-lift

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions