Skip to main content

How do you test infrastructure as code (Terraform, Pulumi)?

  • infrastructure as code
  • terraform
  • IaC testing

Answer it first, then compare. Nothing here is saved or scored.

Model answer

Testing layers: (1) Linting and validation: terraform validate, tflint. (2) Plan review: terraform plan output in PR comments. (3) Unit tests: test modules in isolation with mock providers (Terratest, terraform test). (4) Integration tests: apply to a test environment, verify resources exist, destroy. (5) Policy tests: OPA/Sentinel to enforce organizational rules (no public S3 buckets, required tags). (6) Drift detection: regularly plan against production to detect manual changes. (7) Cost estimation: infracost to predict cost impact of changes.

What interviewers listen for

  • Pipeline shape
    You design stages by failure cost and runtime budget, not by tool feature lists.
  • Parallelisation craft
    You can shard a real suite and explain the state-isolation choices you made.
  • Quality gates
    You know which checks block merge, which warn, and why those defaults are correct.
  • Shift-left fluency
    You talk about ownership transfer, not just earlier execution.

See all 34 ci/cd questions

Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026