1. Apply a security group directly

What you will try

Create an empty security group in the lab VPC. Watch Terraform propose one resource and Argo automatically proceed to apply.

1. Check EKS and the workflow

Complete Prepare EKS for the labs. In the eks-lab working directory with the rendered files, check the context and read the manifest before submitting it.

kubectl config current-context
kubectl -n argo-workflows get workflowtemplate iacstack-direct-aws-sg
cat rendered/direct-stack.yaml

Terraform execution flow

Where is this scenario’s pipeline?

Request: direct-stack.yaml · Alias registration: controller-values.yaml · Full pipeline: direct.yaml.

In the WorkflowTemplate named iacstack-direct-aws-sg, entrypoint: pipeline calls Validate → Plan → Apply. Validate checks the Terraform configuration; Plan writes the proposed changes to the log and saves the plan for Apply. If there are changes, Argo goes straight to Apply. There is no HTML report, OPA, or approval pause.

Plan and Apply still use the controller’s execution authorization to bind the run to the saved plan. This happens automatically without a human decision. The runner publishes execution-result, which the controller reads to update the stack.

Follow the intent into Terraform

In rendered/direct-stack.yaml, sourceRef declares the repository, path and revision; in this example version: v4.13.0 selects a tag. workflowRef.name selects a registered workflow. inputs is a map the workflow interprets. Follow the plan step in workflows/direct.yaml to scripts/security-group/plan.sh and look for iacstack intent read: it reads the intent passed to the runner.

The example uses the community module terraform-aws-modules/security-group/aws and HashiCorp’s hashicorp/aws provider. In the CR, spec.inputs.vpc_id is the value that reaches the module. This is the rendered manifest with an illustrative VPC ID:

apiVersion: iacstack.io/v1alpha1
kind: IaCStack
metadata:
  name: direct-apply-security-group
  namespace: platform-system
spec:
  sourceRef:
    repository: https://github.com/terraform-aws-modules/terraform-aws-security-group.git
    path: examples/complete
    version: v4.13.0
  workflowRef:
    name: direct-aws-sg
  inputs:
    vpc_id: "vpc-0123456789abcdef0"
  lifecycle:
    deletionPolicy: Retain

In the plan step of the direct workflow, the runner reads .intent.inputs.vpc_id, checks it against the allowed sandbox VPC, and exports TF_VAR_vpc_id. The Terraform root in terraform/security-group/main.tf passes var.vpc_id to the module. The controller forwards the inputs; the workflow defines how they map to Terraform variables.

To use your own module, set sourceRef to your repository, path and revision, and select a WorkflowTemplate that accepts it. That workflow can map your spec.inputs to Terraform variables and use your runner, backend and permissions. The lab template deliberately checks the repository, path and stack names, so editing only sourceRef won’t work with this specific template. See Bring your own pipeline for an adaptable example.

2. Submit the request

kubectl apply --dry-run=server -f rendered/direct-stack.yaml
kubectl apply -f rendered/direct-stack.yaml
kubectl -n platform-system get iacstack direct-apply-security-group -w

When the attempt appears, stop watching with Ctrl+C. Copy the name returned below and open that workflow in the Argo list.

STACK=direct-apply-security-group
WF=$(kubectl -n platform-system get iacstack "$STACK" -o jsonpath='{.status.execution.workflow}')
kubectl -n argo-workflows get workflow "$WF"

3. Read the plan in Argo

In the graph, open Terraform-Plan → Logs → main. On the first run, look for Plan: 1 to add, 0 to change, 0 to destroy. and confirm that the proposed resource is a security group in the lab VPC. This scenario uses only the native Terraform log. The manual approval lab introduces the HTML report.

Argo continues to Terraform-Apply without pausing. When there are no changes, the stack reports NoChanges and Apply is skipped.

4. Verify the effect in AWS

  1. Wait for Terraform-Apply to finish in Argo. Check the stack for Verified:

    kubectl -n platform-system get iacstack "$STACK" -o json | jq '.status'
    
  2. In the AWS session you used for setup, list security groups with the expected name in the lab VPC. The first column shows the new ID (starting with sg-):

    bash lab-aws.sh ec2 describe-security-groups \
      --filters "Name=vpc-id,Values=$(cat rendered/vpc-id)" "Name=group-name,Values=iacstack-lab-sg" \
      --query 'SecurityGroups[].[GroupId,GroupName,VpcId]' --output table
    
  3. Expect one row with the name iacstack-lab-sg and your VPC ID. To verify the group by ID, use the value returned above:

    read -r -p 'Security group ID returned by AWS: ' SG_ID
    bash lab-aws.sh ec2 describe-security-groups --group-ids "$SG_ID" \
      --query 'SecurityGroups[].[GroupId,GroupName,VpcId]' --output table
    

2. Apply with approval · Lab teardown