TA-002-P · Question #88
Terraform validate reports syntax check errors from which of the following scenarios?
The correct answer is B. There is missing value for a variable. The terraform validate command checks for configuration syntax errors, inconsistent types, and missing mandatory variable values. It specifically reports errors when a required variable has no default value and no value is provided.
Question
Terraform validate reports syntax check errors from which of the following scenarios?
Options
- ACode contains tabs indentation instead of spaces
- BThere is missing value for a variable
- CThe state files does not match the current infrastructure
- DNone of the above
How the community answered
(25 responses)- B96% (24)
- D4% (1)
Why each option
The `terraform validate` command checks for configuration syntax errors, inconsistent types, and missing mandatory variable values. It specifically reports errors when a required variable has no default value and no value is provided.
`terraform validate` does not check for stylistic issues like indentation (tabs vs. spaces); that is typically handled by `terraform fmt`.
`terraform validate` checks if the configuration is syntactically valid and internally consistent, including validating variable definitions. If a mandatory variable is declared without a default value and no value is provided via `.tfvars` file, CLI argument, or environment variable, `terraform validate` will report this as an error because the configuration is incomplete.
`terraform validate` only checks the configuration files, not the live infrastructure or its consistency with the state file. Checking state-to-infrastructure consistency is part of `terraform plan` or manual inspection.
Since option B is correct, this option is incorrect.
Concept tested: Terraform validate command functionality
Source: https://developer.hashicorp.com/terraform/cli/commands/validate
Topics
Community Discussion
No community discussion yet for this question.