Format and Validate

View saved

Format files

Canonical formatting reduces noisy diffs.

terraform fmt
terraform fmt -recursive

Validate configuration

Checks syntax and internal consistency after init.

terraform init
terraform validate

Typical early errors

  • Missing required provider block or init not run
  • Typos in resource type names
  • Wrong variable types
  • Referring to attributes that do not exist

Add a simple script

Optional npm-style habit: a shell alias or Makefile target that runs fmt, validate, then plan.

Comments

One comment per signed-in account. Comments are saved with this page’s URL.