Composable pipeline labs
Development preview. Each lab has a complete WorkflowTemplate. Open its workflow.yaml and edit the steps directly. The controller does not require these scripts, HTML, Checkov, or OPA. A custom pipeline only needs to follow the execution contract.
1. Prepare a disposable Kind cluster
Follow the Kind quickstart to set up Kind, Argo, and the argo-workflows/iacstack-quickstart ServiceAccount. Check out dev/v0.1.0-alpha.3 and run from the repository root. This upgrade replaces aliases only in the lab cluster. Do not run it against a shared environment. kubectl apply -k packages files into versioned ConfigMaps and applies the checked-in YAML; it does not generate steps or choose the flow.
KIND_CLUSTER=iacstack-quickstart
docker build --platform linux/amd64 --target controller -t iacstack-controller:compose-dev .
docker build --platform linux/amd64 --target runner-opentofu -t iacstack-runner-opentofu:compose-dev .
kind load docker-image iacstack-controller:compose-dev iacstack-runner-opentofu:compose-dev --name "$KIND_CLUSTER"
kubectl apply -f config/crd/iacstack.yaml
kubectl apply -k examples/composable-pipeline
helm upgrade --install iacstack-controller ./charts/iacstack-controller \
--namespace platform-system --wait \
-f examples/composable-pipeline/controller-values.yaml \
--set image.repository=iacstack-controller --set image.tag=compose-dev
To use Terraform, build and load the runner-terraform target, set IAC_ENGINE=terraform in settings.env, and update runner-image in the workflow you will run. Make sure the stack namespace, ServiceAccount and alias match the manifests.
2. Run direct apply, then choose what to add
kubectl apply -f examples/composable-pipeline/direct/stack.yaml
kubectl -n platform-system get iacstack compose-direct -w
Expect Ready with reason Verified on the first apply. Check the result with kubectl -n iacstack-quickstart get configmap compose-direct -o yaml. For each other example, apply the stack.yaml next to its workflow.
| YAML you edit | What it shows |
|---|---|
direct/workflow.yaml | Validate → Plan → Apply, without a pause. |
manual/workflow.yaml | Changed plan → review → suspend. Only Approve calls apply-approved. |
opa/workflow.yaml | OPA reads plan changes. Deny blocks, RequireApproval pauses, and AutoApply continues. |
checkov/workflow.yaml | Checkov scans the HCL. Only Pass calls apply-approved. |
combined/workflow.yaml | Checkov must pass first. OPA then decides what happens next. |
Every flow reports NoChanges when plan-exit == 0, or follows the lab’s branch when the plan has changes (== 2). Protected flows use apply-approved to ask for technical authorization before Apply. Apply recomputes the identity, uses the same saved plan, and verifies the outcome.
3. Edit the WorkflowTemplate
Add OPA
Compare direct/workflow.yaml with opa/workflow.yaml. In plan, replace the empty profiles argument with your workflow’s list:
- - name: plan
template: plan
arguments:
parameters:
- name: profiles
value: '["baseline","kind"]'
Plan writes /workspace/policy-input.json from actual plan changes. On a changed plan, the governed-change template runs opa before authorization. Its when conditions consume steps.opa.outputs.result. In the combined lab, the workflow enters this path only after Checkov returns Pass.
Try deny-me as the message input to block, or review-me to pause. Profiles belong to the workflow; the stack selects an alias. Out-of-scope modules do not vote. An error or uncovered change cannot reach Apply. PCI and non-PCI examples do not certify compliance. To add a rule, add the Rego module to its profile, the ConfigMap, and the OPA step’s --data arguments. Reapply with kubectl apply -k; keep ConfigMaps referenced by active runs.
Add approval
In the manual lab, pipeline.steps calls review for any changed plan. In the OPA lab it does so only for this verdict:
- - name: review
template: review
when: '{{steps.opa.outputs.result}} == RequireApproval'
arguments:
parameters:
- name: plan-id
value: '{{inputs.parameters.plan-id}}'
Open review and approval in the same file. The first reports waiting, calls the gate, and consumes steps.approval.outputs.parameters.approval. The second is Argo’s suspend template. approval-ttl sets the deadline and Reject is the default. The YAML reports Blocked on rejection and calls apply-approved on approval, passing the same identity to authorize and apply.
Native Argo approval is the default. To submit decisions through Kubernetes, enable the optional managed gate that binds approval to the published plan: terminal approval walkthrough.
Insert your own check
For example, insert these two snippets in the direct lab: the first in pipeline.steps before Apply; the second alongside the templates, not inside the steps list. The check uses the runner image and reads the intent through the CLI.
# In direct/workflow.yaml, under pipeline.steps, before the Apply group:
- - name: check-message
template: check-message
when: '{{steps.plan.outputs.parameters.plan-exit}} == 2'
# Add this sibling under spec.templates:
- name: check-message
container:
image: '{{workflow.parameters.runner-image}}'
command: [bash, -euc]
args:
- 'message="$(iacstack intent get inputs.message)"; test "${#message}" -le 80'
env:
- {name: INTENT, value: '{{workflow.parameters.intent}}'}
- {name: WORKFLOW, value: '{{workflow.name}}'}
Reapply with kubectl apply -k examples/composable-pipeline. Trigger a new run by changing spec.inputs.message and watch the new step. An unsuccessful check stops the sequence. For a functional block rather than an operational failure, use the Checkov pattern: publish a decision, report Blocked, and make only the success condition reach Apply.
Use S3 for state if needed
Kubernetes is the default. In a disposable environment with an existing private bucket and an AWS identity for the runner, edit these keys in settings.env before the first run, then reapply with kubectl apply -k examples/composable-pipeline. Replace the sample bucket, region and prefix.
IACSTACK_BACKEND=s3
IACSTACK_S3_BUCKET=your-private-state-bucket
IACSTACK_S3_REGION=us-east-1
IACSTACK_S3_PREFIX=labs/composable
All five labs isolate state at <prefix>/<stack>/terraform.tfstate and use server-side encryption and a .tflock file. Keep bucket versioning and public-access blocking on. Restrict the runner to its prefix and, if applicable, the KMS key; only the lock needs delete permission. Do not change the backend of a stack with existing state. For role chaining, set ASSUME_ROLE_FIRST and optionally ASSUME_ROLE_SECOND, with the AWS CLI in the runner. Do not put credentials in this file.
S3 state is separate from Argo artifact storage. For optional HTML, configure a private Argo artifact repository, set REPORT_ENABLED to "true" in the plan template, and add this output:
# Add under the existing outputs of the plan template, alongside parameters:
artifacts:
- name: plan-review
path: /tmp/plan.html
archive: {none: {}}
Open an example HTML report
. It summarizes changes without raw values. The binary plan is not part of the report. In your own workflow, terraform show -json tfplan | iacstack report plan --output plan.html works with tofu show as well.
Where each part lives
| File | Responsibility |
|---|---|
<lab>/workflow.yaml | Order, inputs, outputs, conditions, approval gate, and local step templates. |
<lab>/stack.yaml | Selects the registered alias and passes the desired intent. |
controller-values.yaml | Maps aliases to Argo templates and their execution contract. |
kustomization.yaml | Packages data and applies manifests without composing steps. |
settings.env | Selects engine and state backend without holding credentials. |
scripts/validate.sh | Validates the module from the pinned commit. |
scripts/plan.sh | Saves the plan and emits optional review or OPA files. |
scripts/apply.sh | Verifies plan identity, claims permission when required, and applies. |
scripts/opa.sh | Evaluates changes using workflow-owned profiles. |
scripts/checkov.py | Scans HCL and returns Pass or Block. |
scripts/authorize.sh | Requests technical authorization for the saved plan; does not decide whether approval is needed. |
scripts/approval-request.sh | Publishes the optional managed approval request. |
scripts/helpers/ | Shares execution context, state configuration, and authentication. |
Kind uses ConfigMaps as example workloads and does not provision AWS. S3 tests simulate the service and execute the direct and Checkov + OPA flows. Real EKS role, state locking, and artifact repository validation remain pending.