HashiCorp Certified: Terraform Associate — Question 317
When should you run terraform init?
Answer options
- A. Every time you run terraform apply
- B. After you run terraform plan for the first time in a new Terraform project and before you run terraform apply
- C. After you start coding a new Terraform project and before you run terraform plan for the first time
- D. Before you start coding a new Terraform project
Correct answer: C
Explanation
The correct answer is C because terraform init prepares the working directory for a new Terraform project, setting up the necessary files and modules before the first terraform plan. Options A and B suggest running terraform init at inappropriate times, while option D implies running it before any code starts, which is not the correct sequence.