Courseiva
Understand Terraform basicshardMultiple ChoiceObjective-mapped

TF-004 Understand Terraform basics Practice Question

A Terraform configuration includes a module from the Terraform Registry. After running `terraform init`, the module is downloaded. However, a subsequent `terraform plan` fails with an error that a required provider is not installed, even though it is declared in the module. What is the most likely cause?

⚠ Common exam trap

HashiCorp often tests the misconception that provider declarations in child modules are automatically inherited by the root module, leading candidates to overlook the necessity of a root-level `required_providers` block.

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

The `required_providers` block is not declared in the root module

In Terraform, the `required_providers` block must be declared in the root module to ensure all providers are installed during `terraform init`. When a module from the Registry declares a provider but the root module does not, `terraform init` may not automatically install that provider, leading to a 'required provider not installed' error during `terraform plan`. The root module acts as the top-level configuration that aggregates all provider requirements.

Answer analysis

Option-by-option breakdown

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

  • The module uses a different Terraform version

    Why it's wrong here

    A Terraform version mismatch would typically manifest during `terraform init` if the configuration syntax is incompatible with the installed CLI version, or during `plan`/`apply` if the state file format is too old or new. Such an error would explicitly mention version incompatibility or parsing failures, rather than indicating a missing provider that couldn't be found.

  • The provider version constraint is incompatible

    Why it's wrong here

    An incompatible provider version constraint would prevent `terraform init` from successfully installing the required provider. The error message would clearly state that no suitable provider version could be found that satisfies all specified constraints across the root and child modules, halting the initialization process before any `plan` or `apply` could occur.

  • The `required_providers` block is not declared in the root module

    Why this is correct

    Terraform's provider installation mechanism primarily relies on the `required_providers` block within the root module to determine which providers need to be downloaded and configured. Even if a child module internally declares a provider, Terraform will not install it unless the root module explicitly includes that provider in its own `required_providers` block. This omission leads to a "provider not found" error when Terraform attempts to use the provider during `plan` or `apply`.

  • The module source URL is incorrect

    Why it's wrong here

    An incorrect module source URL would cause `terraform init` to fail immediately and conspicuously. The error would indicate an inability to fetch the module itself, perhaps due to a non-existent repository, an invalid path, or authentication issues. This failure would occur long before Terraform attempts to resolve or use any providers declared within that module.

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.