TF-004 Interact with Terraform modules Practice Question
Your team is developing a custom module for creating EC2 instances with attached EBS volumes. The module variables are: instance_type (default "t2.micro"), ami (required), volume_size (default 8), volume_type (default "gp2"). Another team uses this module to create a web server. In their root module, they call the module without any explicit instance_type override, but they do set other variables. After applying, the web server is created with instance_type "t2.nano" instead of the expected "t2.micro". They confirm that the module still has the default "t2.micro". What is the most likely explanation?
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 root module has a variable called instance_type set to "t2.nano" that is being passed to the module.
In Terraform, when a module is called, any variable with the same name in the root module that is explicitly passed to the module block (e.g., instance_type = var.instance_type) will override the module's default value, even if the module itself has a default. The root module likely declared a variable instance_type with a default of 't2.nano' and is passing it to the module call. Option A is incorrect because the module's default is 't2.micro', not 't2.nano'. Option B is incorrect because if the variable is not defined in the module's variables.tf, passing it would cause an error; it cannot fall back to an AWS provider default. Option D is incorrect because the scenario explicitly states the module default remains 't2.micro'.
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's instance_type variable uses a default that is "t2.nano" but the root module overrode it with a variable from its own context.
Why it's wrong here
This contradicts the given fact that the module's default is "t2.micro".
- ✗
The instance_type variable is not defined in the module's variables.tf, so it uses a default from the AWS provider.
Why it's wrong here
If the variable is not defined, Terraform would return an error, not silently use a different value.
- ✓
The root module has a variable called instance_type set to "t2.nano" that is being passed to the module.
Why this is correct
If the root module defines or inherits an instance_type variable with value "t2.nano", and the module block passes it (e.g., instance_type = var.instance_type), that overrides the module's default.
- ✗
The module's variable default was changed to "t2.nano" in a new version.
Why it's wrong here
The scenario states the module's default is still "t2.micro".
Go deeper
Related to this question
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 →
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.