Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 256

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?

    Correct Answer: B

    Terraform will use the version recorded in your lock file. The .terraform-lock.hcl file is used to ensure consistency and reproducibility by locking the specific versions of providers in use. This guarantees that the provider version remains the same for both existing and new resources, preventing any inconsistencies or unexpected changes due to updates in provider versions.

Discussion
DevoteamAnalytixOption: B

https://developer.hashicorp.com/terraform/language/files/dependency-lock#dependency-installation-behavior

simoziyadiOption: B

B is correct

Foram31Option: B

When Terraform encounters a new resource that uses the same provider, it will consult the .terraform-lock.hcl file to determine the version of the provider to use for that resource. This ensures consistency in the versions used across resources in the configuration and helps maintain reproducibility.