HashiCorp Certified: Terraform Associate — Question 156

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

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 resources. The other options are incorrect as they suggest using either the latest version or checking the state file, which do not align with Terraform's locking mechanism.