nerdexam
HashiCorp

TA-002-P · Question #91

Module variable assignments are inherited from the parent module and do not need to be explicitly set.

The correct answer is B. False. Module input variables must be explicitly assigned values in the module call block; they are not automatically inherited from the parent module's scope.

Interact with Terraform modules

Question

Module variable assignments are inherited from the parent module and do not need to be explicitly set.

Options

  • ATrue
  • BFalse

How the community answered

(38 responses)
  • A
    8% (3)
  • B
    92% (35)

Why each option

Module input variables must be explicitly assigned values in the module call block; they are not automatically inherited from the parent module's scope.

ATrue

This is false because Terraform enforces explicit variable assignment in module calls; variables from the parent namespace are never automatically propagated to child modules.

BFalseCorrect

In Terraform, each module operates in its own isolated namespace, and the parent module must explicitly pass values to child module variables within the module call block. There is no implicit variable inheritance across module boundaries - Terraform will return an error for any required variable not assigned in the module call unless it has a default value defined. This explicit passing is required regardless of whether the parent module has a variable of the same name.

Concept tested: Terraform module variable scoping and explicit assignment

Source: https://developer.hashicorp.com/terraform/language/modules/syntax#calling-a-child-module

Topics

#Terraform modules#Module variables#Variable passing#Module inheritance

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice