Build a pipeline from scratch
Begin with the working quickstart. The WorkflowTemplate and RBAC implements the steps below. The snippets explain each part, not separate manifests to apply.
1. Declare the entrypoint and identity
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: iacstack-governed-lab
namespace: argo-workflows
spec:
entrypoint: pipeline
serviceAccountName: iacstack-quickstart
arguments:
parameters:
- name: intent
The controller fills the intent. The ServiceAccount needs target/backend permissions and Argo task-result permissions; authorization adds get on IaCStack and patch on status. The lab restricts this to three named stacks; production also needs claim-only admission enforcement.
2. Design stages
| Step | Responsibility | Contract |
|---|---|---|
| plan | Validate intent, resolve Git and binding, init, validate, save plan | resolve and plan token |
| policy | OPA evaluates a small plan-derived document | Argo step result |
| progress | Report whether approval is needed | execution-state |
| approval | Optional suspend, Reject default | Argo supplied output |
| authorize | Policy decision, request token or terminal result | authorization-request/result |
| apply | Verify token, claim, apply saved plan, verify | claim and Verified |
3. Choose the image per step
Use an official runner via script.image or container.image, or your own runner with the CLI. Pass INTENT and WORKFLOW to CLI steps. OPA uses a separate image and mounted policy. Stage names and tooling are yours to define.
4. Resolve and transport
Validate repository/path and existing binding, honor pinnedReference, resolve an immutable commit, then publish the CLI output:
outputs:
parameters:
- name: resolved-source
globalName: resolved-source
valueFrom:
path: /tmp/resolved-source
The example saves workspace and binary plan on a per-workflow PVC. The token binds plan hash, revision, binding, intent hash and engine. OPA reads a small decision document, not the state. See Workspace and artifacts.
5. Approval is not authorization
iacstack authorization request --token "$TOKEN"
# Complete request step and publish the global output.
# In a separate apply step, verify saved plan and context:
iacstack authorization claim --token "$TOKEN" --timeout 30s
# Apply the verified saved plan and verify the outcome.
Use distinct request and mutation steps. No-change apply reports NoChanges; denial or rejection reports Blocked; failures fail the step. Verified requires actual verification. See Execution CLI reference.
6. Register and test
The complete Helm values register the alias and map all signals. Three stack manifests exercise policy decisions with the same workflow. To register the alias and test an intent, follow Create a WorkflowTemplate. Compare policy outcomes in the OPA labs. Production requires stronger workspace integrity, provenance, target validation, locking and admission rules than this educational lab.
Next: Migrate GitHub Actions.