Skip to content
Latchkey

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-color

In 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →