What is the purpose of the .terraform.lock.hcl file?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

What is the purpose of the .terraform.lock.hcl file?

Explanation:
The file serves to lock provider versions so runs are reproducible. It records which providers your configuration uses, the exact versions that were resolved, their sources, and a checksum for each provider binary. When you run Terraform init again, Terraform reads this lock file and installs the same provider versions, ensuring consistent behavior across machines and environments. This prevents unexpected upgrades from happening just because new provider versions exist. The lock file is generated and updated by Terraform and is about locking provider dependencies, not about blocking runs or storing workspace data.

The file serves to lock provider versions so runs are reproducible. It records which providers your configuration uses, the exact versions that were resolved, their sources, and a checksum for each provider binary. When you run Terraform init again, Terraform reads this lock file and installs the same provider versions, ensuring consistent behavior across machines and environments. This prevents unexpected upgrades from happening just because new provider versions exist. The lock file is generated and updated by Terraform and is about locking provider dependencies, not about blocking runs or storing workspace data.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy