Bitzu

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

Single choice

What does terraform validate verify?

  1. That the cloud account has enough quota
  2. That the saved state matches real infrastructure
  3. That all provider credentials are valid
  4. 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.

Select all that apply

Which problems can terraform validate detect?

  1. The AMI ID does not exist in the target region
  2. An unsupported argument name inside a resource block
  3. The cloud credentials have expired
  4. A reference to a variable that was never declared
  5. 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.

True or false

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.

Download on the App StoreGet it on Google Play

More Terraform Associate 004 topics in this module