HashiCorp Certified: Terraform Associate — Question 125
You are making changes to existing Terraform code to add some new infrastructure.
When is the best time to run terraform validate?
Answer options
- A. After you run terraform plan so you can validate that your state file is consistent with your infrastructure
- B. Before you run terraform plan so you can validate your code syntax
- C. Before you run terraform apply so you can validate your infrastructure changes
- D. After you run terraform apply so you can validate that your infrastructure is reflected in your code
Correct answer: B
Explanation
The correct answer is B because running terraform validate before terraform plan helps to catch any syntax errors in your configuration files early on. Options A, C, and D are incorrect because they suggest validating after planning or applying, which does not address potential syntax issues in the code before those steps.