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
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ spec:

capabilities:
- cloudflare-domain.setup
- cloudflare-domain.aws-credentials
- cloudflare-domain.env
- cloudflare-domain.context
- cloudflare-domain.fmt
- cloudflare-domain.init
- cloudflare-domain.workspace
- cloudflare-domain.validate
- cloudflare-domain.plan
- cloudflare-domain.apply
Expand All @@ -32,16 +30,6 @@ spec:
terraform_version: "{{.parameters.terraformVersion}}"
terraform_wrapper: "false"

- id: aws-credentials
name: Configure AWS Credentials
capability: cloudflare-domain.aws-credentials
use: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: "arn:aws:iam::{{.parameters.awsAccountId}}:role/{{.orun.environment.name}}-github-{{.parameters.owner}}-{{.parameters.repo}}-plan"
aws-region: "{{.parameters.awsRegion}}"
audience: sts.amazonaws.com
onFailure: stop

- id: terraform-env
name: Export Terraform Env
capability: cloudflare-domain.env
Expand Down Expand Up @@ -89,21 +77,7 @@ spec:

terraform -chdir={{ .parameters.terraformDir }} init \
-input=false \
-reconfigure \
-backend-config="bucket={{.parameters.orgName}}-{{.orun.environment.name}}" \
-backend-config="key={{.parameters.repo}}/{{.orun.component.name}}/terraform.tfstate" \
-backend-config="region=${AWS_REGION:-{{.parameters.awsRegion}}}"
onFailure: stop

- id: terraform-workspace
name: Workspace
capability: cloudflare-domain.workspace
shell: bash
run: |
set -euo pipefail

terraform -chdir={{ .parameters.terraformDir }} workspace select -or-create {{ .orun.environment.name }}
echo "TF_WORKSPACE={{ .orun.environment.name }}" >> "$ORUN_ENV"
-reconfigure
onFailure: stop

- id: terraform-validate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ spec:
cloudflare-domain:
includeCapabilities:
- cloudflare-domain.setup
- cloudflare-domain.aws-credentials
- cloudflare-domain.env
- cloudflare-domain.context
- cloudflare-domain.fmt
- cloudflare-domain.init
- cloudflare-domain.workspace
- cloudflare-domain.validate
- cloudflare-domain.plan
- cloudflare-domain.apply
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ spec:
cloudflare-domain:
includeCapabilities:
- cloudflare-domain.setup
- cloudflare-domain.aws-credentials
- cloudflare-domain.env
- cloudflare-domain.context
- cloudflare-domain.fmt
- cloudflare-domain.init
- cloudflare-domain.workspace
- cloudflare-domain.validate
- cloudflare-domain.plan
5 changes: 0 additions & 5 deletions compositions/cloudflare-domain/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ spec:
type: string
terraformVersion:
type: string
awsAccountId:
type: string
description: AWS account ID hosting the GitHub-OIDC role this component assumes
awsRegion:
type: string
orgName:
type: string
owner:
Expand Down
6 changes: 3 additions & 3 deletions compositions/cloudflare-worker-turbo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ be hydrated from an escrow after deploy.
- **Optional wiring parameters:** `wranglerTemplate` (empty means a legacy
committed config and the wiring steps no-op), `wiringComponents`,
`wiringEnvs` (default `stage,prod`), `wiringFixture` (default
`wiring.fixture.json`), `runtimeSecrets`, `awsAccountId`, `awsRegion` (default
`wiring.fixture.json`), `runtimeSecrets` (default
`us-east-1`), `orgName`, `owner`, `repo`

## Profiles
Expand All @@ -38,9 +38,9 @@ Each file in `profiles/` selects steps from the job by capability.
| ------------------ | ----- |
| `pull-request` | setup-node → setup-pnpm → install → verify-structure → build → typecheck |
| `verify` (default) | `pull-request` steps + wire-fixture (offline render) and deploy-dry-run — never needs cloud credentials |
| `deploy` | setup → install → verify-structure → wire-fixture → build → typecheck → wire-credentials → wire-live → pre-deploy → migrate → deploy → secrets-live → smoke; requires approval and a clean git tree |
| `deploy` | setup → install → verify-structure → wire-fixture → build → typecheck → wire-live → pre-deploy → migrate → deploy → secrets-live → smoke; requires approval and a clean git tree |

`wire-credentials` and `wire-live` are deploy-only by design so verify lanes stay
`wire-live` is deploy-only by design so verify lanes stay
credential-free; both no-op for components without a `wranglerTemplate`, and
`secrets-live` pushes the component's orun-resolved runtime secrets (`runtimeSecrets` names, best-effort via `optionalSecretEnv`) and no-ops for components without them.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ spec:
- cloudflare-worker-turbo.build
- cloudflare-worker-turbo.typecheck
- cloudflare-worker-turbo.deploy-dry-run
- cloudflare-worker-turbo.wire-credentials
- cloudflare-worker-turbo.wire-live
- cloudflare-worker-turbo.pre-deploy
- cloudflare-worker-turbo.migrate
Expand Down Expand Up @@ -106,29 +105,27 @@ spec:
run: "pnpm exec wrangler deploy --dry-run --config {{ .parameters.wranglerConfig }} --env {{ .orun.environment.name }}"
onFailure: stop

- id: wire-credentials
name: wire-credentials
capability: cloudflare-worker-turbo.wire-credentials
use: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: "arn:aws:iam::{{.parameters.awsAccountId}}:role/{{.orun.environment.name}}-github-{{.parameters.owner}}-{{.parameters.repo}}-plan"
aws-region: "{{.parameters.awsRegion}}"
audience: sts.amazonaws.com
onFailure: stop

- id: wire-live
name: wire-live
capability: cloudflare-worker-turbo.wire-live
shell: bash
run: |
{{- if .parameters.wranglerTemplate }}
set -euo pipefail
# Wiring documents come from orun secrets (de-AWS): each infra component
# pushed its outputs as WIRING_<COMPONENT> on the project/<env> rung
# (terraform wire-secrets step), and THIS component declares them in
# secretEnv as WIRING_<COMPONENT>_<ENV> — the runner resolves them into
# the step env, so the render input is plain env-var indirection.
wiring_dir=$(mktemp -d)
for comp in $(echo "{{ .parameters.wiringComponents }}" | tr ',' ' '); do
for wenv in $(echo "{{ .parameters.wiringEnvs }}" | tr ',' ' '); do
aws secretsmanager get-secret-value \
--secret-id "{{ .parameters.orgName }}/{{ .parameters.repo }}/${comp}/${wenv}" \
--query SecretString --output text > "${wiring_dir}/${comp}__${wenv}.json"
var="WIRING_$(echo "${comp}" | tr 'a-z-' 'A-Z_')_$(echo "${wenv}" | tr 'a-z' 'A-Z')"
if [ -z "${!var:-}" ]; then
echo "wire-live: ${var} is empty — declare it in this component's secretEnv (secret://<ws>/<project>/${wenv}/WIRING_$(echo "${comp}" | tr 'a-z-' 'A-Z_'))" >&2
exit 1
fi
printf '%s' "${!var}" > "${wiring_dir}/${comp}__${wenv}.json"
done
done
node {{ .parameters.workspaceDir }}/tooling/wire/render.mjs \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ spec:
- cloudflare-worker-turbo.typecheck
# BF6: resolve binding IDs from the Secrets Manager wiring manifest at
# deploy time (no-op for workers without a wrangler template).
- cloudflare-worker-turbo.wire-credentials
- cloudflare-worker-turbo.wire-live
- cloudflare-worker-turbo.pre-deploy
- cloudflare-worker-turbo.migrate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
- cloudflare-worker-turbo.install
- cloudflare-worker-turbo.verify-structure
# Offline fixture render only — verify lanes must never need cloud
# credentials (BF6 D5 guard); wire-credentials/wire-live are deploy-only.
# credentials (BF6 D5 guard); wire-live is deploy-only.
- cloudflare-worker-turbo.wire-fixture
- cloudflare-worker-turbo.build
- cloudflare-worker-turbo.typecheck
Expand Down
6 changes: 0 additions & 6 deletions compositions/cloudflare-worker-turbo/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ spec:
type: string
default: ""
description: Comma-separated env var names the secrets-live step pushes as the worker's runtime secrets. Each name resolves from orun secrets via the component's optionalSecretEnv (best-effort — unseeded names are skipped and reported); empty = the step skips.
awsAccountId:
type: string
description: AWS account ID hosting the GitHub-OIDC role wire-live assumes to read wiring secrets
awsRegion:
type: string
default: us-east-1
orgName:
type: string
owner:
Expand Down
7 changes: 2 additions & 5 deletions compositions/db-migrate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ the run belongs to.
- **Job:** `migrate` (default) — `jobs/db-migrate-run.yaml`
- **Default profile:** `apply`
- **Required parameters:** `nodeVersion`, `pnpmVersion`, `secretName`
- **Optional parameters:** `awsAccountId` (AWS account ID hosting the
GitHub-OIDC role this component assumes), `awsRegion`, `owner`, `repo`
- **Optional parameters:** `owner`, `repo`

`awsAccountId`, `awsRegion`, `owner`, and `repo` are optional in the schema but
are all interpolated into the `aws-credentials` step, so a component that runs
either profile in CI needs them set.

## Profiles
Expand All @@ -33,7 +30,7 @@ Each file in `profiles/` selects steps from the job by capability.

| Profile | Steps |
| ----------------- | ----- |
| `plan` | setup-node → setup-pnpm → install → build → aws-credentials → plan. Reports pending migrations without mutating the database; used on pull requests. |
| `plan` | setup-node → setup-pnpm → install → build → plan. Reports pending migrations without mutating the database; used on pull requests. |
| `apply` (default) | the same setup steps followed by `apply` instead of `plan`. Applies pending migrations to the live database post-merge. |

`setup-pnpm` is declared before `setup-node` in the job so `setup-node` can warm
Expand Down
11 changes: 0 additions & 11 deletions compositions/db-migrate/jobs/db-migrate-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ spec:
- db-migrate.setup-pnpm
- db-migrate.install
- db-migrate.build
- db-migrate.aws-credentials
- db-migrate.plan
- db-migrate.apply

Expand Down Expand Up @@ -51,16 +50,6 @@ spec:
run: pnpm exec turbo run build --filter=@saas/db
onFailure: stop

- id: aws-credentials
name: Configure AWS Credentials
capability: db-migrate.aws-credentials
use: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: "arn:aws:iam::{{.parameters.awsAccountId}}:role/{{.orun.environment.name}}-github-{{.parameters.owner}}-{{.parameters.repo}}-plan"
aws-region: "{{.parameters.awsRegion}}"
audience: sts.amazonaws.com
onFailure: stop

- id: migrate-plan
name: Migration Plan
capability: db-migrate.plan
Expand Down
1 change: 0 additions & 1 deletion compositions/db-migrate/profiles/db-migrate-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ spec:
- db-migrate.setup-pnpm
- db-migrate.install
- db-migrate.build
- db-migrate.aws-credentials
- db-migrate.apply
1 change: 0 additions & 1 deletion compositions/db-migrate/profiles/db-migrate-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ spec:
- db-migrate.setup-pnpm
- db-migrate.install
- db-migrate.build
- db-migrate.aws-credentials
- db-migrate.plan
5 changes: 0 additions & 5 deletions compositions/db-migrate/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ spec:
type: string
pnpmVersion:
type: string
awsAccountId:
type: string
description: AWS account ID hosting the GitHub-OIDC role this component assumes
awsRegion:
type: string
secretName:
type: string
owner:
Expand Down
11 changes: 6 additions & 5 deletions compositions/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ 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 |
| `awsAccountId` | no | AWS account ID hosting the GitHub-OIDC role this component assumes |
| `orgName` | no | Organization name (used for S3 bucket naming) |
| `awsRegion` | no | AWS region override |
| `wireSecrets` | no | Comma-separated `KEY=output` pairs pushed to orun secrets after apply (the de-AWS wiring channel) |
| `orgName` | no | Organization name |
| `owner` | no | GitHub org owner |
| `repo` | no | GitHub repo name |
| `namespace` | no | Logical namespace |
Expand All @@ -37,8 +36,10 @@ Each file in `profiles/` selects steps from the `terraform` job by capability.

### `plan-only`

Non-mutating validation: setup, AWS credentials, env export, context, fmt, init,
workspace, validate, plan. Used on pull requests to preview changes.
Non-mutating validation: setup, env export, context, fmt, init, validate, plan
(state served by the platform's terraform HTTP backend via runner-exported
TF_HTTP_* — no cloud credentials step, no workspaces). Used on pull requests
to preview changes.

### `apply` (default)

Expand Down
60 changes: 33 additions & 27 deletions compositions/terraform/jobs/terraform-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ spec:

capabilities:
- terraform.setup
- terraform.aws-credentials
- terraform.env
- terraform.context
- terraform.fmt
- terraform.init
- terraform.workspace
- terraform.validate
- terraform.plan
- terraform.apply
- terraform.wire-secrets

steps:
- id: setup-terraform
Expand All @@ -32,16 +31,6 @@ spec:
terraform_version: "{{.parameters.terraformVersion}}"
terraform_wrapper: "false"

- id: aws-credentials
name: Configure AWS Credentials
capability: terraform.aws-credentials
use: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: "arn:aws:iam::{{.parameters.awsAccountId}}:role/{{.orun.environment.name}}-github-{{.parameters.owner}}-{{.parameters.repo}}-plan"
aws-region: "{{.parameters.awsRegion}}"
audience: sts.amazonaws.com
onFailure: stop

- id: terraform-env
name: Export Terraform Env
capability: terraform.env
Expand Down Expand Up @@ -82,26 +71,16 @@ spec:
name: Init
capability: terraform.init
shell: bash
# State lives on the platform (SB1): the runner exports TF_HTTP_* per job
# (address = …/state/tfstate/{component}/{env}, run token as password), so
# `backend "http"` needs no -backend-config and no AWS credentials step.
# The environment is IN the address — no terraform workspaces.
run: |
set -euo pipefail

terraform -chdir={{ .parameters.terraformDir }} init \
-input=false \
-reconfigure \
-backend-config="bucket={{.parameters.orgName}}-{{.orun.environment.name}}" \
-backend-config="key={{.parameters.repo}}/{{.orun.component.name}}/terraform.tfstate" \
-backend-config="region=${AWS_REGION:-{{.parameters.awsRegion}}}"
onFailure: stop

- id: terraform-workspace
name: Workspace
capability: terraform.workspace
shell: bash
run: |
set -euo pipefail

terraform -chdir={{ .parameters.terraformDir }} workspace select -or-create {{ .orun.environment.name }}
echo "TF_WORKSPACE={{ .orun.environment.name }}" >> "$ORUN_ENV"
-reconfigure
onFailure: stop

- id: terraform-validate
Expand All @@ -121,3 +100,30 @@ spec:
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.
run: |
{{- if .parameters.wireSecrets }}
set -euo pipefail
org=$(printf '%s' "$TF_HTTP_ADDRESS" | sed -E 's#.*/organizations/([^/]+)/projects/.*#\1#')
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 }}"
echo "wired $key ← output/$output"
done
{{- else }}
echo "wire-secrets: no wireSecrets declared; skipping."
{{- end }}
onFailure: stop
3 changes: 1 addition & 2 deletions compositions/terraform/profiles/terraform-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ spec:
terraform:
includeCapabilities:
- terraform.setup
- terraform.aws-credentials
- terraform.env
- terraform.context
- terraform.fmt
- terraform.init
- terraform.workspace
- terraform.validate
- terraform.plan
- terraform.apply
- terraform.wire-secrets
Loading
Loading