What is the purpose of the .terraform.lock.hcl file, and how should it normally be handled?
- A.
It stores the state of your infrastructure and should be kept out of Git.
- B.
It holds secret variable values and must never be shared.
- C.
It locks the state backend while a plan is running.
- D.
It records the exact provider versions and checksums selected by
terraform init, and it should be committed to version control.
Show answer and explanation
Answer: D
The dependency lock file makes later runs select the same provider versions, so teammates and CI behave consistently.
- It stores the state of your infrastructure and should be kept out of Git.: That is the state file, not the lock file.
- It holds secret variable values and must never be shared.: It contains provider versions and hashes, not secrets.
- It locks the state backend while a plan is running.: State locking is handled by the backend.