HashiCorp
TERRAFORM-ASSOCIATE-004 · Question #170
When does Terraform create the .terraform.lock.hc1 file?
The correct answer is C. After your first terraform init. Terraform creates the .terraform.lock.hcl file after the first terraform init command. This lock file ensures that the dependencies for your project are consistent across different runs by locking the versions of the providers and modules used.
Submitted by hassan_iq· Apr 18, 2026Use Terraform CLI
Question
When does Terraform create the .terraform.lock.hc1 file?
Options
- AAfter your first terraform plan
- BAfter your first terraform apply
- CAfter your first terraform init
- DWhen you enable state locking
How the community answered
(55 responses)- A5% (3)
- B2% (1)
- C91% (50)
- D2% (1)
Explanation
Terraform creates the .terraform.lock.hcl file after the first terraform init command. This lock file ensures that the dependencies for your project are consistent across different runs by locking the versions of the providers and modules used.
Topics
#terraform init#provider locking#dependency lock file#Terraform CLI
Community Discussion
No community discussion yet for this question.