TERRAFORM-ASSOCIATE-003 practice question 1 of 30
[Understand Terraform Basics and CLI] If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform Init.
Full set: 226 questionsThe .terraform.lock.hcl file records the specific versions of providers that Terraform has selected to use for a configuration. The terraform init command is responsible for initializing a working directory, which includes downloading and installing the necessary providers based on the version constraints defined in the configuration files. When terraform init is executed, it compares the version constraints in the configuration with the versions recorded in the lock file. If the constraints have been updated in a way that the locked version no longer satisfies them, Terraform will find the newest available provider version that meets the new constraint, download it, and update the .terraform.lock.hcl file to record the newly selected version and its checksum.
The "False" option is incorrect because it contradicts the fundamental dependency management workflow of Terraform. The primary mechanism for updating provider dependencies and the corresponding lock file is the terraform init command. If init did not update the lock file after a constraint change, the lock file would become outdated and no longer reflect the actual dependencies required by the configuration, defeating its purpose of ensuring consistent and repeatable builds.
1. HashiCorp Terraform Documentation, "Dependency Lock File (.terraform.lock.hcl)": In the section "Managing Selections in the Lock File," the documentation explicitly states: "If you change the version constraints for a provider in your configuration, the next time you run terraform init Terraform will select the newest-available provider version that meets the new constraint and update the lock file accordingly."
2. HashiCorp Terraform Documentation, "Command: init": Under the "Provider Installation" section, it describes the role of terraform init in downloading and installing providers. It notes, "If a lock file is present (.terraform.lock.hcl), terraform init will also check that the installed provider versions are consistent with the checksums recorded in the lock file..." This implies that init is the command that manages the relationship between the configuration, the installed providers, and the lock file.
3. HashiCorp Terraform Documentation, "Provider Requirements": This page details how to declare provider version constraints within the requiredproviders block. It establishes that these constraints are the source of truth that terraform init uses to select an appropriate provider version, which is then recorded in the lock file.
Keep practicing
Take the free TERRAFORM-ASSOCIATE-003 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other TERRAFORM-ASSOCIATE-003 practice questions
- Question 2[Navigate Terraform State and Backends] Terraform variable names are saved in the state f…
- Question 3[Understand Terraform Basics and CLI] You modified your Terraform configuration and run T…
- Question 4[Understand Terraform Basics and CLI] You must use different Terraform commands depending…
- Question 6[Understand Terraform Basics and CLI] terraform init creates an example main.tf file in t…
- Question 7[Understand Terraform Basics and CLI] terraform validate confirms that your infrastructur…
- Question 8[Interact with Terraform Modules] All modules published on the official Terraform Module …
