Terraform Associate 004 ยท Core Terraform workflow
terraform validate
Syntax and internal consistency checks, no API calls, requires init, what it does not catch (3c).
Key points
- Checks that the configuration is syntactically valid and internally consistent (attribute names, value types, references) regardless of variable values or state.
- It does not call remote services or provider APIs, so it cannot tell whether a value is accepted by the cloud.
- The directory must be initialized first; terraform init -backend=false is enough.
- Use -json for machine-readable output.
Source: https://developer.hashicorp.com/terraform/cli/commands/validate
Practice questions
What does terraform validate verify?
- That the cloud account has enough quota
- That the saved state matches real infrastructure
- That all provider credentials are valid
- That the configuration is syntactically valid and internally consistent
Show answer
Answer: D. That the configuration is syntactically valid and internally consistent
validate is a local check of syntax and internal consistency. Quota, drift and credentials need remote calls, which validate does not make.
Which problems can terraform validate detect?
- The AMI ID does not exist in the target region
- An unsupported argument name inside a resource block
- The cloud credentials have expired
- A reference to a variable that was never declared
- The bucket name is already taken by another account
Show answer
Answer: B. An unsupported argument name inside a resource block, D. A reference to a variable that was never declared
Unknown arguments and undeclared references are internal-consistency errors found locally. Missing images, expired credentials and name clashes only appear when talking to the remote service.
terraform validate calls the provider API to confirm that each value will be accepted by the cloud.
Show answer
Answer: False
False. validate checks syntax and consistency locally; it does not validate remote services. Plan, which includes an implied validation, is where such problems surface.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
