terraform validate Command Reference
A fast, offline syntax-and-consistency check before you hit the cloud.
terraform validate checks whether a configuration is syntactically valid and internally consistent. It makes no provider API calls, so it is the cheapest early CI gate.
What it does
terraform validate verifies that arguments, references, and types are correct within the module. It needs provider schemas (so init must run first) but never contacts provider APIs or reads remote state.
Common flags and usage
- -json: emit machine-readable results for CI annotations
- -no-color: disable ANSI color in logs
- Run terraform init -backend=false first so schemas are available without credentials
Example
shell
- name: Validate
run: |
terraform init -backend=false -input=false
terraform validate -no-colorIn CI
Use validate as an early gate that runs on every PR before plan. Init with -backend=false keeps the stage fast and credential-free, since validate needs only provider schemas, not backend access.
Key takeaways
- validate is offline: it never calls provider APIs or reads remote state.
- Run init -backend=false first so schemas load without credentials.
- It is the cheapest early gate; place it before plan on every PR.
Related guides
terraform fmt Command ReferenceReference for terraform fmt in CI/CD: enforce canonical HCL formatting, run a -check gate across the tree, an…
terraform init Command ReferenceReference for terraform init in CI/CD: initialize providers, modules, and the backend, pass backend-config, a…
terraform plan Command ReferenceReference for terraform plan in CI/CD: preview changes, save a plan file with -out for a later apply, and gat…