exam questions

Exam Terraform Associate 003 All Questions

View all questions & answers for the Terraform Associate 003 exam

Exam Terraform Associate 003 topic 1 question 4 discussion

Actual exam question from HashiCorp's Terraform Associate 003
Question #: 4
Topic #: 1
[All Terraform Associate 003 Questions]

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?

  • 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.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
hbouachir
1 month ago
Selected Answer: B
B. Terraform will use the version recorded in your lock file. ✅ Here’s why: The .terraform.lock.hcl file locks provider versions for your working directory. This ensures consistent behavior across runs, so Terraform uses the same provider version for all resources, even when you add new resources. The version constraint in your configuration (required_providers) defines which versions are allowed, but Terraform will prioritize the version in the lock file if it satisfies the constraint. Terraform does not check the state file to pick a provider version—the state only tracks infrastructure resources. It does not automatically use the latest provider version unless you explicitly run terraform init -upgrade and the new version satisfies the constraints.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...