Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compositions/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
46 changes: 14 additions & 32 deletions compositions/terraform/jobs/terraform-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ spec:
- terraform.validate
- terraform.plan
- terraform.apply
- terraform.wire-secrets

steps:
- id: setup-terraform
Expand Down Expand Up @@ -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 <output>`
# 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
1 change: 0 additions & 1 deletion compositions/terraform/profiles/terraform-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ spec:
- terraform.validate
- terraform.plan
- terraform.apply
- terraform.wire-secrets
11 changes: 6 additions & 5 deletions compositions/terraform/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading