terraform-validate
Validate Terraform configuration syntax and internal consistency
TLDR
SYNOPSIS
terraform validate [options]
DESCRIPTION
terraform validate checks whether the Terraform configuration files in a working directory are syntactically valid and internally consistent. It verifies attribute names, value types, and module structure without contacting remote services such as remote state backends or provider APIs.Validation requires an initialized working directory with referenced providers and modules installed. For local checks without configuring a backend, run terraform init -backend=false first. To validate configuration in the context of a specific workspace, variables, and state, use terraform plan, which includes an implied validation step.The command is safe to run automatically as a post-save editor check or as a CI step for reusable modules. With -json, results include valid, error_count, warning_count, and a diagnostics array describing each issue.
PARAMETERS
-json
Produce machine-readable JSON output (disables color). Suitable for editor integrations and CI.-no-color
Disable color in human-readable output.-var 'NAME=VALUE'
Set a single root-module input variable. May be repeated.-var-file FILENAME
Load variable values from a .tfvars file. May be repeated.
INSTALL
CAVEATS
Does not replace terraform plan: remote resource existence, provider API behavior, and runtime variable constraints are not fully exercised. An uninitialized directory will fail until plugins and modules are installed. Exit status is non-zero when errors are detected; warnings alone do not make the configuration invalid.
SEE ALSO
terraform(1), terraform-init(1), terraform-plan(1), terraform-fmt(1)