HashiCorp Certified: Terraform Associate (003) — Question 4
You add a new resource to an existing Terraform configuration, but do not update the version constraint in the configuration. The existing and new resources use the same provider. The working directory contains a .terraform.lock.hcl file.
How will Terraform choose which version of the provider to use?
Answer options
- A. Terraform will use the latest version of the provider for the new resource and the version recorded in the lock file to manage existing resources.
- B. Terraform will use the version recorded in your lock file.
- C. Terraform will check your state file to determine the provider version to use.
- D. Terraform will use the latest version of the provider available at the time you provision your new resource.
Correct answer: B
Explanation
The correct answer is B because Terraform prioritizes the version specified in the .terraform.lock.hcl file to ensure consistency across the environment. Options A and D are incorrect as they imply using different versions, which could lead to discrepancies. Option C is also incorrect since the state file does not dictate the provider version in this scenario.