Courseiva
Interact with Terraform moduleshardMultiple SelectObjective-mapped

TF-004 Interact with Terraform modules Practice Question

Which THREE files are considered part of the standard module structure?

⚠ Common exam trap

HashiCorp often tests the distinction between files that are part of the standard module structure versus files that are commonly used but not mandatory, such as `backend.tf` or `terraform.tfvars`, leading candidates to overcount or misidentify required files.

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

main.tf

`main.tf` is the primary entry point for defining the core resources and data sources in a Terraform module. It is one of the three mandatory files (along with `variables.tf` and `outputs.tf`) that constitute the standard module structure, as specified by HashiCorp's module best practices.

Answer analysis

Option-by-option breakdown

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

  • main.tf

    Why this is correct

    The main.tf file is conventionally used to define the primary resources, data sources, and local values that constitute the core functionality of a Terraform module. It serves as the central point for the module's infrastructure provisioning logic, making it an essential component for any standard module. Its presence is fundamental for the module to perform its intended infrastructure creation or management tasks, encapsulating the module's primary purpose.

  • outputs.tf

    Why this is correct

    The outputs.tf file is where a module declares output values, which are used to expose specific data or attributes from the resources provisioned by the module to its parent module or the root module. These outputs enable other parts of the configuration to reference and utilize information, such as IP addresses or resource IDs, generated by the module, making it a crucial interface for module reusability and integration.

  • backend.tf

    Why it's wrong here

    The backend.tf file is specifically used to configure the Terraform backend, which determines where Terraform stores its state file. Backend configuration is a global setting for a given Terraform working directory and is typically defined only once in the root module of a configuration. Reusable child modules should never define their own backend, as this would conflict with the root module's state management and prevent proper module composition.

  • terraform.tfvars

    Why it's wrong here

    The terraform.tfvars file, or any `.tfvars` file, is used to provide concrete values for input variables declared within a Terraform configuration. These files are typically located in the root module or passed explicitly during `terraform plan` or `terraform apply` commands. They are not considered part of a module's *definition* or *structure*, as they supply runtime input rather than defining the module's inherent capabilities or interface.

  • variables.tf

    Why this is correct

    The variables.tf file is the standard location for declaring input variables that a module expects to receive from its calling configuration. These declarations define the variable's name, type constraints, default values, and descriptions, establishing the module's public interface for customization. Properly defined variables in this file are essential for making a module flexible and reusable across different environments or use cases.

About these practice questions

Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.