CertLumen

HashiCorp Terraform Associate (004) · Section 3 · 12% of the exam

Initialize a Terraform working directory

One of the objectives of the HashiCorp Certified: Terraform Associate (004) exam, in the section “Core Terraform workflow”. Here is what it covers, the points to remember and a question to try.

What it covers

Terraform follows a write, plan, apply loop, and every working directory must be initialized first. This lesson shows where each command fits, what terraform init installs and creates, how the dependency lock file pins providers, and which init options the exam expects you to know.

Points to remember

  • The workflow is write, plan, apply; init comes first in any new or cloned directory.
  • terraform init initializes the backend, installs modules and providers, and writes .terraform.lock.hcl.
  • Init is safe to repeat and never changes infrastructure.
  • The lock file tracks provider versions and checksums only (not modules) and is committed to version control.
  • terraform init -upgrade ignores the lock file selections and takes the newest versions allowed by the constraints.

Try a question

A cloud engineer clones a Git repository that contains a Terraform configuration and nothing else. No Terraform command has been run in the new directory. Which command must be run first before terraform plan or terraform validate can work?

  1. Aterraform init
  2. Bterraform plan
  3. Cterraform apply
  4. Dterraform validate
Show the answer

A. A freshly cloned configuration has no provider plugins, no module copies and no lock file. terraform init creates all of that. Every other core command depends on it.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson The Terraform workflow and terraform init teaches this objective (about 35 minutes), and 12 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 37 objectives · Next objective →