From 8412651adcc693948b2d28792086169dc9a75bbb Mon Sep 17 00:00:00 2001 From: Rahul Varghese Date: Tue, 28 Jul 2026 16:36:14 +0530 Subject: [PATCH] =?UTF-8?q?feat!:=20secretOutputs=20=E2=80=94=20lease-publ?= =?UTF-8?q?ished=20job=20output=20secrets=20replace=20wire-secrets=20(0.18?= =?UTF-8?q?.0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The apply step queues declared terraform outputs on the runner's $ORUN_SECRET_OUTPUTS sink (heredoc form, multiline-safe); the RUNNER publishes them post-success over the run's lease-bound channel and the platform derives the target scope from the leased job (orun >= v2.45.0, orun-cloud SEC-JOB). The wire-secrets step, its capability, and every scrap of in-shell auth/scope plumbing are gone — and CI holds no ambient secret-write authority at all. Param rename: wireSecrets → secretOutputs (same KEY=output grammar). Co-Authored-By: Claude Fable 5 --- compositions/terraform/README.md | 2 +- .../terraform/jobs/terraform-validate.yaml | 46 ++++++------------- .../terraform/profiles/terraform-apply.yaml | 1 - compositions/terraform/schema.yaml | 11 +++-- stack.yaml | 2 +- 5 files changed, 22 insertions(+), 40 deletions(-) diff --git a/compositions/terraform/README.md b/compositions/terraform/README.md index c5b2f3c..d653727 100644 --- a/compositions/terraform/README.md +++ b/compositions/terraform/README.md @@ -22,7 +22,7 @@ Repo-local Orun composition for Terraform infrastructure components. | `stackName` | yes | Logical name of the Terraform stack | | `terraformDir` | yes | Relative path to the Terraform root module | | `terraformVersion` | yes | Pinned Terraform CLI version | -| `wireSecrets` | no | Comma-separated `KEY=output` pairs pushed to orun secrets after apply (the de-AWS wiring channel) | +| `secretOutputs` | no | Comma-separated `KEY=output` pairs queued on the runner sink after apply and published over the lease-bound channel (SEC-JOB) | | `orgName` | no | Organization name | | `owner` | no | GitHub org owner | | `repo` | no | GitHub repo name | diff --git a/compositions/terraform/jobs/terraform-validate.yaml b/compositions/terraform/jobs/terraform-validate.yaml index e5897da..98bae94 100644 --- a/compositions/terraform/jobs/terraform-validate.yaml +++ b/compositions/terraform/jobs/terraform-validate.yaml @@ -20,7 +20,6 @@ spec: - terraform.validate - terraform.plan - terraform.apply - - terraform.wire-secrets steps: - id: setup-terraform @@ -98,42 +97,25 @@ spec: - id: terraform-apply name: Apply capability: terraform.apply - run: "terraform -chdir={{ .parameters.terraformDir }} apply -no-color -auto-approve" - onFailure: stop - - - id: wire-secrets - name: Wire outputs to orun secrets - capability: terraform.wire-secrets shell: bash - # Post-apply secret WRITES go through orun (no Secrets Manager): each - # KEY=output pair in wireSecrets pushes `terraform output -raw ` - # into the project/{{env}} secret rung via `orun secrets set` (value over - # stdin — never echoed, never in argv). Downstream consumers read the - # same keys back as secretEnv references. The (org, project) scope is - # parsed from the runner-exported TF_HTTP_ADDRESS, so this step needs no - # extra parameters and works in any workspace the run targets. + # SEC-JOB: declared outputs are appended to the runner's secret-outputs + # sink INSIDE the apply step — no extra sync step, no CLI, no auth. The + # RUNNER publishes them post-success over the run's lease-bound channel; + # the platform derives the target scope (project/env rung) from the + # leased job itself. secretOutputs: "KEY=output,KEY2=output2". run: | - {{- if .parameters.wireSecrets }} set -euo pipefail - # Backend + scope from the runner-exported state address (org_…/prj_… - # public ids) — the step may run outside the repo root, so the CLI - # cannot rely on intent.yaml or a repo link for any of the three. - export ORUN_BACKEND_URL=$(printf '%s' "$TF_HTTP_ADDRESS" | sed -E 's#(https?://[^/]+)/.*#\1#') - export ORUN_WORKSPACE=$(printf '%s' "$TF_HTTP_ADDRESS" | sed -E 's#.*/organizations/([^/]+)/projects/.*#\1#') - export ORUN_PROJECT=$(printf '%s' "$TF_HTTP_ADDRESS" | sed -E 's#.*/projects/([^/]+)/state/.*#\1#') - tmp=$(mktemp) - trap 'rm -f "$tmp"' EXIT - for pair in $(echo "{{ .parameters.wireSecrets }}" | tr ',' ' '); do + terraform -chdir={{ .parameters.terraformDir }} apply -no-color -auto-approve + {{- if .parameters.secretOutputs }} + for pair in $(echo "{{ .parameters.secretOutputs }}" | tr ',' ' '); do key="${pair%%=*}" output="${pair#*=}" - terraform -chdir={{ .parameters.terraformDir }} output -raw "$output" > "$tmp" - # First deploy creates; later deploys append a version (set 409s on - # an existing key). Value travels via file+stdin — never argv/echo. - orun secrets set "$key" --env "{{ .orun.environment.name }}" < "$tmp" \ - || orun secrets rotate "$key" --env "{{ .orun.environment.name }}" < "$tmp" - echo "wired $key ← output/$output" + { + printf '%s<<__ORUN_EOF__\n' "$key" + terraform -chdir={{ .parameters.terraformDir }} output -raw "$output" + printf '\n__ORUN_EOF__\n' + } >> "${ORUN_SECRET_OUTPUTS:?runner did not provide the secret-outputs sink}" + echo "queued secret output $key ← output/$output" done - {{- else }} - echo "wire-secrets: no wireSecrets declared; skipping." {{- end }} onFailure: stop diff --git a/compositions/terraform/profiles/terraform-apply.yaml b/compositions/terraform/profiles/terraform-apply.yaml index a031d83..6934326 100644 --- a/compositions/terraform/profiles/terraform-apply.yaml +++ b/compositions/terraform/profiles/terraform-apply.yaml @@ -16,4 +16,3 @@ spec: - terraform.validate - terraform.plan - terraform.apply - - terraform.wire-secrets diff --git a/compositions/terraform/schema.yaml b/compositions/terraform/schema.yaml index 652071c..5f7b30e 100644 --- a/compositions/terraform/schema.yaml +++ b/compositions/terraform/schema.yaml @@ -25,13 +25,14 @@ spec: - terraformDir - terraformVersion properties: - wireSecrets: + secretOutputs: type: string description: >- - Comma-separated KEY=output pairs pushed to orun secrets after - apply (project/env rung, value over stdin). The de-AWS wiring - channel: downstream consumers read the same keys as secretEnv - references — no Secrets Manager. + Comma-separated KEY=output pairs (SEC-JOB): after apply, each + terraform output is queued on the runner's secret-outputs sink + and PUBLISHED by the runner over the run's lease-bound channel + onto the project/env rung. Downstream consumers read the same + keys as secretEnv references — no Secrets Manager, no CLI step. lane: type: string namespace: diff --git a/stack.yaml b/stack.yaml index 0b5d460..9d25520 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,7 +3,7 @@ kind: Stack metadata: name: stack-tectonic title: Stack Tectonic - version: 0.17.3 + version: 0.18.0 description: Versioned OCI-hosted catalog of Cloudflare, Terraform and monorepo compositions for Sourceplane repositories. owner: sourceplane tags: