From 0f1962204261098e3005bd8ea52c21adf1cc3397 Mon Sep 17 00:00:00 2001 From: Rahul Varghese Date: Mon, 27 Jul 2026 20:48:42 +0530 Subject: [PATCH 1/2] feat(secrets): resolve CLOUDFLARE_API_TOKEN through orun secrets (phase 1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Cloudflare deploy credential becomes an orun-managed brokered secret — minted fresh per run from the Cloudflare integration (workers-deploy template: Workers Scripts Write + Workers KV Storage Write + Account Settings Read), stored as secret://lumen/lumen//CLOUDFLARE_API_TOKEN at the project rung, lease-bound resolved and log-redacted at run time. - stack-tectonic 0.13.0 → 0.14.0: the cloudflare-worker-turbo and cloudflare-workers-assets-turbo deploy profiles now declare the token as a secretBinding; PR/verify lanes carry no refs and resolve nothing. - cloudflare-kv declares it via component secretEnv (its plan lanes hit the live Cloudflare API too, so all profiles need it). - The three CF terraform stacks drop variable cloudflare_api_token and authenticate the provider from the env var natively — the token no longer transits Terraform variables; TF_VAR_cloudflare_api_token is removed from CI. - orun v2.20.0 → v2.39.0: resolved-secret env delivery to gha steps (v2.35.0) + the component-tree secretEnv fix (#573). - The ambient CLOUDFLARE_API_TOKEN GH secret remains ONLY for cloudflare-hyperdrive (needs Workers Hyperdrive Write) and cloudflare-domain (needs DNS Write) until the broker templates cover those scopes; CLOUDFLARE_ACCOUNT_ID stays ambient (identifier, not a credential). Co-Authored-By: Claude Fable 5 --- .github/workflows/ci.yml | 14 +++++++++++--- .../terraform/cloudflare-domain/terraform/main.tf | 14 ++++---------- .../cloudflare-hyperdrive/terraform/main.tf | 15 ++++----------- infra/terraform/cloudflare-kv/README.md | 1 - infra/terraform/cloudflare-kv/component.yaml | 6 ++++++ infra/terraform/cloudflare-kv/terraform/main.tf | 15 ++++----------- intent.yaml | 2 +- 7 files changed, 30 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27ec4d2..009c982 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: fetch-depth: 0 - uses: sourceplane/orun-action@v1.2.0 with: - version: v2.20.0 + version: v2.39.0 - env: # Surface the best-effort catalog auto-sync (execution.state.autopushCatalog). # A successful push prints "✓ pushed catalog …"; ORUN_VERBOSE also makes @@ -79,7 +79,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - uses: sourceplane/orun-action@v1.2.0 with: - version: v2.20.0 + version: v2.39.0 - run: | orun run \ --plan plan.json \ @@ -90,11 +90,19 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # CLOUDFLARE_API_TOKEN is now an orun-managed brokered secret + # (secret://lumen/lumen//CLOUDFLARE_API_TOKEN, minted fresh per + # run from the Cloudflare integration): worker deploys receive it via + # the deploy profile's secretBindings, cloudflare-kv via its + # component secretEnv — the resolved value overrides this ambient one. + # The ambient copy remains ONLY for cloudflare-hyperdrive and + # cloudflare-domain, whose Terraform needs Hyperdrive/DNS permissions + # the workers-deploy broker template does not mint yet. Remove it when + # those two components migrate. CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} SUPABASE_API_KEY: ${{ secrets.SUPABASE_API_KEY }} SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_API_KEY }} - TF_VAR_cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }} TF_VAR_cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} # Supabase org id is environment/account-specific, so it comes from a # CI secret rather than a committed component parameter. Used by the diff --git a/infra/terraform/cloudflare-domain/terraform/main.tf b/infra/terraform/cloudflare-domain/terraform/main.tf index bc5f20b..98dd5b9 100644 --- a/infra/terraform/cloudflare-domain/terraform/main.tf +++ b/infra/terraform/cloudflare-domain/terraform/main.tf @@ -34,9 +34,10 @@ provider "aws" { } } -provider "cloudflare" { - api_token = var.cloudflare_api_token -} +# Authenticates via the CLOUDFLARE_API_TOKEN env var (provider-native): the +# token is an orun-managed secret resolved into the job env at run time, so it +# never transits Terraform variables. +provider "cloudflare" {} # --- Variables (standard Orun parameters) --- @@ -45,13 +46,6 @@ variable "awsRegion" { default = "us-east-1" } -variable "cloudflare_api_token" { - type = string - sensitive = true - default = "" - description = "Cloudflare API token (from CLOUDFLARE_API_TOKEN env var)" -} - variable "cloudflare_account_id" { type = string sensitive = true diff --git a/infra/terraform/cloudflare-hyperdrive/terraform/main.tf b/infra/terraform/cloudflare-hyperdrive/terraform/main.tf index 8177494..0152882 100644 --- a/infra/terraform/cloudflare-hyperdrive/terraform/main.tf +++ b/infra/terraform/cloudflare-hyperdrive/terraform/main.tf @@ -34,10 +34,10 @@ provider "aws" { } } -# Authenticates via CLOUDFLARE_API_TOKEN env var -provider "cloudflare" { - api_token = var.cloudflare_api_token -} +# Authenticates via the CLOUDFLARE_API_TOKEN env var (provider-native): the +# token is an orun-managed secret resolved into the job env at run time, so it +# never transits Terraform variables. +provider "cloudflare" {} # --- Variables (standard Orun parameters) --- @@ -46,13 +46,6 @@ variable "awsRegion" { default = "us-east-1" } -variable "cloudflare_api_token" { - type = string - sensitive = true - default = "" - description = "Cloudflare API token with Hyperdrive permissions (from CLOUDFLARE_API_TOKEN env var)" -} - variable "cloudflare_account_id" { type = string sensitive = true diff --git a/infra/terraform/cloudflare-kv/README.md b/infra/terraform/cloudflare-kv/README.md index e2ed188..6f460f9 100644 --- a/infra/terraform/cloudflare-kv/README.md +++ b/infra/terraform/cloudflare-kv/README.md @@ -61,7 +61,6 @@ Standard Orun parameters (matching `cloudflare-hyperdrive`): | Name | Type | Default | Description | |---|---|---|---| | `awsRegion` | string | `us-east-1` | AWS region for Terraform state backend | -| `cloudflare_api_token` | string (sensitive) | `""` | From `CLOUDFLARE_API_TOKEN` env var | | `cloudflare_account_id` | string (sensitive) | `""` | From `CLOUDFLARE_ACCOUNT_ID` env var | | `orgName` | string | `lumen` | Org identifier | | `owner` | string | `lumen` | GitHub owner | diff --git a/infra/terraform/cloudflare-kv/component.yaml b/infra/terraform/cloudflare-kv/component.yaml index e1612ce..7e37f02 100644 --- a/infra/terraform/cloudflare-kv/component.yaml +++ b/infra/terraform/cloudflare-kv/component.yaml @@ -23,6 +23,12 @@ spec: env: AWS_EC2_METADATA_DISABLED: "true" + # The Cloudflare Terraform provider authenticates via the CLOUDFLARE_API_TOKEN + # env var, resolved by orun from the project-rung brokered secret (fresh per + # run, Deploy Workers scope). Declared at component level because plan-only + # lanes refresh against the live Cloudflare API too, not just apply. + secretEnv: + CLOUDFLARE_API_TOKEN: "secret://lumen/lumen/{{ .environment }}/CLOUDFLARE_API_TOKEN" subscribe: environments: diff --git a/infra/terraform/cloudflare-kv/terraform/main.tf b/infra/terraform/cloudflare-kv/terraform/main.tf index e51aae4..f01290b 100644 --- a/infra/terraform/cloudflare-kv/terraform/main.tf +++ b/infra/terraform/cloudflare-kv/terraform/main.tf @@ -34,10 +34,10 @@ provider "aws" { } } -# Authenticates via CLOUDFLARE_API_TOKEN env var -provider "cloudflare" { - api_token = var.cloudflare_api_token -} +# Authenticates via the CLOUDFLARE_API_TOKEN env var (provider-native): the +# token is an orun-managed secret resolved into the job env at run time, so it +# never transits Terraform variables. +provider "cloudflare" {} # --- Variables (standard Orun parameters) --- @@ -46,13 +46,6 @@ variable "awsRegion" { default = "us-east-1" } -variable "cloudflare_api_token" { - type = string - sensitive = true - default = "" - description = "Cloudflare API token with Workers KV permissions (from CLOUDFLARE_API_TOKEN env var)" -} - variable "cloudflare_account_id" { type = string sensitive = true diff --git a/intent.yaml b/intent.yaml index e593de6..859051d 100644 --- a/intent.yaml +++ b/intent.yaml @@ -31,7 +31,7 @@ compositions: # a commit here. Bumping the tag is the deliberate upgrade step. - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.14.0 resolution: precedence: - stack-tectonic From 37d896cd7798d7e840b993f9a4ccfdab12e69cf0 Mon Sep 17 00:00:00 2001 From: Rahul Varghese Date: Mon, 27 Jul 2026 20:58:08 +0530 Subject: [PATCH 2/2] =?UTF-8?q?chore(domain):=20park=20cloudflare-domain?= =?UTF-8?q?=20=E2=80=94=20its=20zone=20does=20not=20exist=20in=20the=20acc?= =?UTF-8?q?ount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Surfaced by this PR's full fan-out (the stack pin bump replans every component): cloudflare-domain had not planned in CI since the rebrand fork, and its zone lookup can never succeed — lumen.app is parked at dns.ws, not delegated to Cloudflare, and absent from the connected account, so data.cloudflare_zone.existing fails with 'no zone found' regardless of credentials. Unsubscribe it (no jobs) with restore instructions inline; unrelated to the CF-token migration. Co-Authored-By: Claude Fable 5 --- .../cloudflare-domain/component.yaml | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/infra/terraform/cloudflare-domain/component.yaml b/infra/terraform/cloudflare-domain/component.yaml index c1a432a..b60145c 100644 --- a/infra/terraform/cloudflare-domain/component.yaml +++ b/infra/terraform/cloudflare-domain/component.yaml @@ -42,19 +42,28 @@ spec: dependsOn: - component: web-console-next + # PARKED — no environment subscriptions, so no jobs are planned. The zone + # this stack manages (baseDomain lumen.app) is not delegated to Cloudflare + # and does not exist in the connected account (the domain is parked at + # dns.ws — a rebrand artifact), so `data.cloudflare_zone.existing` fails + # every plan with "no zone found". Restore the subscribe block below once + # the zone exists in the account (and finish the 0085b v5 re-import). + # + # subscribe: + # environments: + # - name: stage + # profile: plan-only + # profileRules: + # - profile: apply + # when: + # triggerRef: github-push-main + # + # - name: prod + # profile: plan-only + # profileRules: + # - profile: apply + # when: + # triggerRef: github-push-main subscribe: - environments: - - name: stage - profile: plan-only - profileRules: - - profile: apply - when: - triggerRef: github-push-main - - - name: prod - profile: plan-only - profileRules: - - profile: apply - when: - triggerRef: github-push-main + environments: [] # ci: trigger full-component verification (orun v2.12.0 upgrade — PR #183)