Plain language
terraform validate checks that your configuration is syntactically valid and internally consistent.
Under the hood
validate checks |
validate does not check |
|---|---|
| HCL syntax | Whether credentials work |
| Correct block types and argument names, using provider schemas | Whether a referenced remote object exists (an AMI, a subnet) |
| Required arguments are present | API quotas, permissions, naming collisions |
| References point to declared objects | Variable values from .tfvars files (validation runs without them) |
| Type consistency where values are known | State or drift |
Two more points:
validaterequiresinit, because it needs the provider schemas. In a fresh directory it errors and tells you to runterraform init.terraform validate -jsonproduces machine-readable results for CI.