Skip to content

iac-source-coupled-test

shell test asserts on raw IaC source text

Why

Text searches can pass on comments, formatting, or unreachable Terraform configuration without proving provider or runtime behavior.

Fix

Inspect rendered plan JSON, provider state, or deployed runtime behavior instead of grepping IaC source.

Examples

Before — flagged Do not grep Terraform source in a shell test
tests/observability.test.sh
#!/bin/sh
grep -q 'alert_policy' iac/alerts.tf
After — preferred Query structured rendered plan output
tests/observability.test.sh
#!/bin/sh
terraform show -json plan.out | jq -e '.resource_changes | length > 0'

Files

**/*.sh**/*.bash**/*.zsh