HashiCorp Certified: Terraform Associate — Question 219

When does Terraform create the .terraform.lock.hcl file?

Answer options

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.