Terraform-Associate-004 practice question 2 of 35
Module variable assignments are inherited from the parent module and you do not need to explicitly set them.
Full set: 360 questionsThe statement is incorrect. Child modules in Terraform do not automatically inherit variable values from their parent module. A parent module must explicitly pass values to the input variables declared in the child module. This is done by setting arguments within the module block that calls the child. This explicit passing of variables is a fundamental design principle of Terraform that ensures modules are encapsulated, predictable, and reusable. If a required input variable in a child module is not assigned a value in the module block (and it does not have a default value), Terraform will return an error during the planning phase.
The "True" option is wrong because it describes a behavior of automatic, implicit inheritance. Terraform's module system is designed to be explicit. The interface between a parent and child module is strictly defined by the child's input variables and outputs. Values must be deliberately passed into the module, not assumed or inherited from the parent's scope.
1. HashiCorp Terraform Documentation, "Calling a Child Module": This document explicitly states how to pass values to a child module. It says, "The arguments of a module block correspond to the input variables of the module." The provided examples show explicit assignment for each variable being passed.
Source Reference: In the "Module Arguments" section, it details the syntax: argumentname = . This demonstrates that each value must be explicitly assigned.
2. HashiCorp Terraform Documentation, "Input Variables": This page clarifies the different ways variables can be assigned. For modules, it is unambiguous.
Source Reference: Under the section "Assigning Values to Module Input Variables," the documentation states: "When you call a module from a parent configuration, you set values for its input variables using arguments in the module block." This directly contradicts the idea of automatic inheritance.
3. HashiCorp Terraform Learn, "Create and Use a Local Module": This official tutorial guides users through the process of creating and calling a module, reinforcing the concept of explicit variable passing.
Source Reference: In the section "Pass data with an input variable," the tutorial demonstrates adding a variable "serverport" to a module and then explicitly setting it in the root main.tf file with the line serverport = 8080 inside the module "webserver" block. This practical example shows that assignment is a required, explicit step.
Keep practicing
Take the free Terraform-Associate-004 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Terraform-Associate-004 practice questions
- Question 1You should run terraform fnt to rewrite all Terraform configurations within the current w…
- Question 3terraform validate confirms thesyntaxof Terraform files.
- Question 4Using the terraform state rm command against a resource will destroy it.
- Question 5Variables declared within a module are accessible outside of the module.
- Question 6terraform init retrieves and caches the configuration for all remote modules.
- Question 7terraform validate uses provider APIs to verify your infrastructure settings.
