From a7e0b0ed5a397d50a4b0fa1114efce36ffc4b52d Mon Sep 17 00:00:00 2001 From: Rahul Varghese Date: Tue, 28 Jul 2026 14:55:29 +0530 Subject: [PATCH] fix(terraform): wire-secrets works in CI and on re-deploys (0.17.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Scope via ORUN_WORKSPACE/ORUN_PROJECT parsed from the runner-exported TF_HTTP_ADDRESS — no repo link exists in a CI checkout, and the env slug→id resolve rides the new workflow bound-scope grants (orun-cloud #679/#680). - Re-deploys: `secrets set` 409s on an existing key, so fall back to `secrets rotate` (version append). Value moves via a 600 tmpfile + stdin — never argv, never echoed. Co-Authored-By: Claude Fable 5 --- .../terraform/jobs/terraform-validate.yaml | 14 +++++++++++--- stack.yaml | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compositions/terraform/jobs/terraform-validate.yaml b/compositions/terraform/jobs/terraform-validate.yaml index 9ddbfc4..c22f943 100644 --- a/compositions/terraform/jobs/terraform-validate.yaml +++ b/compositions/terraform/jobs/terraform-validate.yaml @@ -115,12 +115,20 @@ spec: run: | {{- if .parameters.wireSecrets }} set -euo pipefail - org=$(printf '%s' "$TF_HTTP_ADDRESS" | sed -E 's#.*/organizations/([^/]+)/projects/.*#\1#') + # Scope from the runner-exported backend address (org_…/prj_… public + # ids) — no repo link exists in CI, so the CLI reads these env vars. + 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 key="${pair%%=*}" output="${pair#*=}" - terraform -chdir={{ .parameters.terraformDir }} output -raw "$output" | \ - orun secrets set "$key" --org "$org" --project --env "{{ .orun.environment.name }}" + 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" done {{- else }} diff --git a/stack.yaml b/stack.yaml index ad96bd7..494d4a4 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,7 +3,7 @@ kind: Stack metadata: name: stack-tectonic title: Stack Tectonic - version: 0.17.0 + version: 0.17.1 description: Versioned OCI-hosted catalog of Cloudflare, Terraform and monorepo compositions for Sourceplane repositories. owner: sourceplane tags: