Skip to content

ci: core apply fails — the Cloudflare credential is on the plan step but not the apply step #916

Closed

Description

@athvin

Regression from #912 (be64c41e). main has no R2 bucket and apply (core)
is red.

Error: failed to make http request
  with cloudflare_r2_bucket.sccache[0], on r2.tf line 57
400 {"success":false,"errors":[{"code":9106,
     "message":"Missing X-Auth-Key, X-Auth-Email or Authorization headers"}]}

plan (core) passed and the apply jobs own terraform plan (to a file)passed. Onlyterraform applyfailed, because #912 putCLOUDFLARE_API_TOKENandTF_VAR_cloudflare_account_idin the env of the **plan-to-file step** and the apply step carries onlyDIR`.

Why a saved plan still needs the credential

Not a Terraform quirk — the direct consequence of a decision recorded in
versions.tf. Variable values are baked into the plan file; provider
credentials deliberately are not
, which is exactly why the provider reads
CLOUDFLARE_API_TOKEN from the environment instead of taking it as a Terraform
variable (a variable would land in the plan file and in state). So the token has
to be present at plan AND at apply.

TF_VAR_cloudflare_account_id was not the problem — it is in the plan file —
but it moves too, because splitting the two across steps is how they drift.

Fix

Both values move to the apply jobs **job-level** env:`, so plan-to-file and
apply cannot disagree. Fixing the class, not the instance.

Also records the exception in the workflow header, which asserts "NO REPOSITORY
SECRETS, by design and not by omission". That claim survives — this is an
Environment secret on infra-apply-core (protected_branches: true),
reachable by one job on main, and every objection the header raises is about
reach. What does not survive is the expiry argument: a Cloudflare token is
long-lived where every AWS identity here lasts an hour. Cloudflare has no OIDC,
so that is the floor rather than a shortcut.

Not in scope

apply (prod) is also red on the same run, from the WAFv2 § rejection in #555
— pre-existing, and #913 fixes it.

Activity

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