terraform validate
The command that checks a configuration is internally consistent, such as correct syntax, types and references, without contacting any real infrastructure.
In more detail
It needs providers to be installed, so run terraform init first; otherwise it tells you to. It cannot tell whether a cloud will accept a value, only whether the configuration makes sense. Pipelines run it after formatting and before planning.
Example
terraform init -backend=false && terraform validateRelated terms
- terraform fmt — The command that rewrites .tf files into Terraform's one standard layout; it never looks at real infrastructure.
- terraform init — The command that prepares a directory for Terraform: it downloads providers, fetches modules, connects the backend and writes the lock file.
- -backend=false — The init option that skips connecting to the backend, so a pipeline can format, validate or test a configuration without any credentials.
Taught in
- Installing Terraform And Meeting The CLI — Infrastructure as Code with Terraform
- Running Terraform In CI — Infrastructure as Code with Terraform
- Native Testing With Tftest Files — Infrastructure as Code with Terraform
- Provider Mocking For Tests — Infrastructure as Code with Terraform
- Policy As Code With OPA — Infrastructure as Code with Terraform
- Releasing The Real Cloud Artifact — Infrastructure as Code with Terraform
- One Hour, No Weights Published — HashiCorp Terraform Associate (004) Exam Prep
- Providers: How Terraform Reaches Every API — HashiCorp Terraform Associate (004) Exam Prep
- Write, Plan, Apply, And What Init Prepares — HashiCorp Terraform Associate (004) Exam Prep
- Reading A Plan, Saving It, Applying It — HashiCorp Terraform Associate (004) Exam Prep
- Validate, Format, Destroy, And The Flags That Bend A Plan — HashiCorp Terraform Associate (004) Exam Prep
- Module Scope: What Goes In, What Comes Out — HashiCorp Terraform Associate (004) Exam Prep
- Drift: When Reality Stops Matching State — HashiCorp Terraform Associate (004) Exam Prep
- Importing What Terraform Did Not Build — HashiCorp Terraform Associate (004) Exam Prep