Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate 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?

Show Answer
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

3 comments
Sign in to comment
simoziyadiOption: B
Jun 13, 2023

B is correct

DevoteamAnalytixOption: B
Jun 26, 2023

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

Foram31Option: B
Jun 18, 2023

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.