Courseiva
Read, generate and modify configurationeasyMultiple ChoiceObjective-mapped

TF-004 Read, generate and modify configuration Practice Question

Which command initializes a Terraform working directory by downloading providers and modules?

⚠ Common exam trap

Candidates often confuse `terraform init` with `terraform get`, mistakenly thinking `terraform get` handles both providers and modules. In reality, `terraform get` only manages modules while `terraform init` handles providers, modules, and backend initialization.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

terraform init

`terraform init` is the command that initializes a Terraform working directory by downloading and installing the required providers and modules specified in the configuration files. It also sets up the backend for state storage and locks, ensuring the environment is ready for subsequent operations like planning and applying.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • terraform plan

    Why it's wrong here

    The "terraform plan" command generates an execution plan, detailing the infrastructure changes Terraform proposes to make to reach the desired state. However, it cannot function without a properly initialized working directory, which means all required provider plugins and modules must first be downloaded and configured. Attempting to run `terraform plan` before `terraform init` will result in an error because Terraform lacks the necessary binaries to interpret the configuration and interact with cloud APIs.

  • terraform apply

    Why it's wrong here

    The "terraform apply" command is responsible for executing the actions defined in a Terraform plan, provisioning or modifying infrastructure resources. This critical step inherently relies on a fully prepared working directory where all necessary provider plugins are installed and backend configurations are established. Without prior initialization, Terraform cannot connect to the target cloud providers or manage state, making `terraform apply` impossible to run successfully.

  • terraform get

    Why it's wrong here

    The "terraform get" command is specifically designed to download and update modules referenced in the configuration from various sources, such as local paths, Git repositories, or the Terraform Registry. While modules are an important part of many Terraform configurations, `terraform get` does not handle the crucial task of downloading and installing provider plugins. Therefore, it cannot fully initialize a Terraform working directory by itself, as providers are essential for interacting with infrastructure APIs.

  • terraform init

    Why this is correct

    The "terraform init" command is the fundamental operation for preparing a Terraform working directory for use. It performs several essential setup steps, including discovering and downloading all necessary provider plugins, retrieving remote modules, and configuring the backend for state management. This comprehensive initialization ensures that Terraform has all the required components to parse configurations, create execution plans, and apply infrastructure changes effectively.

About these practice questions

This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.