1 / 75 · 08 Infrastructure as Code Testing · Terraform Validation⊞ allnext →☰ Read as one page
1.1The Validation Pyramid
Infrastructure validation follows a pyramid similar to the traditional test pyramid, but with its own layers. Each layer catches different classes of issues at different costs:
/\
/ \ Integration tests (Terratest, real cloud resources)
/ \
/------\ Plan-time analysis (terraform plan, drift detection)
/ \
/----------\ Static analysis (validate, tfsec, checkov)
/ \
/--------------\ Syntax and format (terraform fmt, terraform validate)
/________________\
The bottom of the pyramid is free and fast. The top is expensive and slow but catches issues nothing else can. A mature IaC testing strategy uses all four layers, running the cheap checks on every commit and the expensive checks on critical module changes.