TF-004 Read, generate and modify configuration Practice Question
A junior engineer is asked to review a Terraform configuration that defines a module from the Terraform Registry. In which files are the descriptions of the module’s inputs and outputs typically found?
⚠ Common exam trap
A common trap is to assume one file contains all documentation. While `variables.tf` documents inputs and `outputs.tf` documents outputs, questions asking for the file containing descriptions of both inputs and outputs imply both files are needed. Candidates may incorrectly choose only one.
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
✓
variables.tf
In Terraform modules, input variables are declared in `variables.tf` with `description` arguments to document their purpose, and output values are declared in `outputs.tf` with `description` arguments. Therefore, descriptions of both inputs and outputs are found in these two files. Neither file alone describes both; the question's phrasing implies consideration of both files, making both B and C correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
versions.tf
Why it's wrong here
The `versions.tf` file is specifically designated for declaring required Terraform CLI versions and defining provider version constraints within `terraform` and `provider` blocks. Its purpose is to ensure compatibility and predictable behavior across different execution environments. It does not contain definitions for input variables or output values, nor does it house their associated descriptive metadata.
- ✓
variables.tf
Why this is correct
The `variables.tf` file is the standard and recommended location for defining all input variables that a Terraform module or configuration accepts. Each `variable` block within this file can include a `description` argument, which is essential for clearly documenting the purpose, expected data types, and valid values for each configurable input. These descriptions are crucial for users to understand how to interact with and customize the module.
- ✓
outputs.tf
Why this is correct
The `outputs.tf` file is conventionally used to define all output values that a Terraform module or configuration exposes to its parent module or to the root configuration. Each `output` block within this file supports a `description` argument. This description is vital for clearly explaining what data the output represents, its format, and its intended use, thereby documenting the module's external interface.
- ✗
main.tf
Why it's wrong here
While `main.tf` is frequently used as the primary file for defining core resources (`resource` blocks) and data sources (`data` blocks) that implement the configuration's logic, it is not the conventional or best practice location for defining `variable` or `output` blocks. Placing these interface definitions here would clutter the resource declarations, making the configuration less readable, harder to maintain, and obscuring the module's public interface.
Go deeper
Related to this question
About these practice questions
One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.