Skip to main content

Terraform Validate and Tflint

terraform validate checks that a configuration is syntactically valid and internally consistent without contacting any cloud. TFLint is a separate linter that finds deprecated syntax, invalid provider values, and unused code that validate does not report.

What Are Validate and TFLint?

Validate needs terraform init for provider schemas but no cloud credentials. TFLint adds provider-aware and best-practice rules.

Bash
terraform init -backend=false
terraform validate
tflint --init
tflint --recursive

Run cheap checks first in CI: terraform fmt -check, then validate, then tflint, then terraform plan with real credentials.

Common Mistake

Assuming a passing validate means the code is correct. It will not catch a nonexistent AMI or an overlapping CIDR. Those appear at plan or apply.

Frequently Asked Questions

Why run validate and TFLint if plan reports errors anyway?

They are faster and need no cloud credentials, so they can run on every push. Plan needs real authentication and takes longer.

What does TFLint catch that validate cannot?

Valid but poor code, such as deprecated arguments, invalid instance types, unpinned providers, and unused variables.

Found a mistake, an outdated step or a broken link?