A module can always refer to all variables declared in its parent module.

Prepare for the HashiCorp Terraform Associate Exam. Utilize flashcards and multiple-choice questions with detailed hints and explanations. Boost your confidence and be ready for success!

Multiple Choice

A module can always refer to all variables declared in its parent module.

Explanation:
In Terraform, modules have their own scope for variables. A child module cannot directly access or "see" the variable declarations from its parent. Values go into a module only through input variables that the child defines, and the parent provides those values when calling the module. So if the parent has a variable you want to use in the child, you must declare a corresponding input variable in the child and pass the value from the parent (for example, region = var.region). Alternatively, the parent can export a value via an output and pass it into the child as an input. But there is no automatic linkage where a child can refer to the parent’s var.* directly. This is why the statement is false.

In Terraform, modules have their own scope for variables. A child module cannot directly access or "see" the variable declarations from its parent. Values go into a module only through input variables that the child defines, and the parent provides those values when calling the module. So if the parent has a variable you want to use in the child, you must declare a corresponding input variable in the child and pass the value from the parent (for example, region = var.region). Alternatively, the parent can export a value via an output and pass it into the child as an input. But there is no automatic linkage where a child can refer to the parent’s var.* directly. This is why the statement is false.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy