HashiCorp Certified: Terraform Associate — Question 219
When does Terraform create the .terraform.lock.hcl file?
Answer options
- A. After your first terraform plan
- B. After your first terraform apply
- C. After your first terraform init
- D. Whenever you enable state locking
Correct answer: C
Explanation
The .terraform.lock.hcl file is created after the first execution of 'terraform init,' as this command initializes the working directory and sets up the locking mechanism for provider versions. The other options do not trigger the creation of this lock file; 'terraform plan' and 'terraform apply' are dependent on the initialization process, and state locking is a feature that does not directly relate to the creation of the lock file.