Which command is used to validate Terraform configuration files?

  1. terraform validate ✓
  2. terraform check
  3. terraform verify
  4. terraform test

Correct answer: terraform validate

Option A is correct because 'terraform validate' is the official Terraform CLI command that checks whether configuration files in a directory are syntactically valid and internally consistent without accessing any remote services or state. Option B is incorrect because 'terraform check' is not a valid Terraform CLI command and does not exist in the Terraform toolset. Option C is incorrect because 'terraform verify' is also not a recognized Terraform command. Option D is incorrect because 'terraform test' is a separate command introduced in Terraform 1.6 for running module unit and integration tests written in HCL, not for validating configuration syntax.

Topic: · terraform cli, configuration validation, iac, hashicorp

Practice HashiCorp Terraform Associate (003) Questions Free