Skip to content
Latchkey

terraform validate: Usage, Options & Common CI Errors

A fast, offline syntax-and-consistency check before you ever hit the cloud.

terraform validate checks whether a configuration is syntactically valid and internally consistent. It does not contact any provider API or read state, so it is the cheapest early CI gate.

What it does

terraform validate verifies that arguments, references, and types are correct within the module - undeclared variables, wrong attribute names, and bad expressions are caught here. It requires terraform init first so provider schemas are available, but it never makes network calls to providers.

Common usage

Terminal
# Validate the current configuration (run after init)
terraform init -backend=false
terraform validate

# Machine-readable output for CI annotations
terraform validate -json

Common error in CI: validate run before init

A bare terraform validate in CI fails with "Error: Could not load plugin" or "module is not yet installed - run terraform init". validate needs provider schemas. Fix: run terraform init -backend=false first (no backend/credentials needed for a pure validate gate), then validate. Using -backend=false keeps the lint stage fast and credential-free.

Key options

OptionPurpose
-jsonEmit machine-readable results
-no-colorDisable ANSI color in logs

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →