Terraform

How do you test and lint modules during development?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

terraform -chdir=examples/vpc init
terraform -chdir=examples/vpc validate
terraform -chdir=examples/vpc plan
tflint --module
  • terraform validate catches syntax errors and missing providers.

  • Running plan against an example stack surfaces integration issues before promotion.

  • tflint --module adds provider-specific linting; tools like Terratest can provision ephemeral infra for assertions.

  • Include these commands in CI so every module change is exercised automatically.