Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 91


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

Show Answer
Correct Answer: B

Module variable assignments must be explicitly set by the parent module when it instantiates the child module. Modules do not inherit variables from the parent module. Each module is a self-contained unit, requiring explicit definitions and assignments for its variables.

Discussion

8 comments
Sign in to comment
stalk98Option: B
Jun 8, 2022

Modules do not inherit variables from the parent module. All modules are self-contained units. So you have to explicitly define variables in the child module, and then explicit set these variables in the parent module, when you instantiate the child module.

EltoothOption: B
Jul 6, 2022

B is correct answer : false.

DineshSGOption: B
May 17, 2023

I think we are confused between variable assignment and variable declaration. Variable need to be declared in child module but not necessarily be assigned. We can pass values from parent module

BereOption: B
Oct 19, 2023

Module variable assignments must be explicitly set by the parent module when it instantiates the child module. Variable Declaration in Child Module (modules/vm/main.tf): variable "instance_type" { type = string default = "t2.micro" # This is an optional default value. } resource "aws_instance" "example" { instance_type = var.instance_type ami = "ami-abc123" subnet_id = "subnet-1234abcd" } Variable Assignment in Parent Module (main.tf): module "vm" { source = "./modules/vm" instance_type = "t3.micro" # Assigning a value to the variable. } In this example, instance_type is declared as a variable in the child module and is assigned a value by the parent module when it instantiates the vm module. The value "t3.micro" assigned by the parent module will override the default value "t2.micro" declared in the child module.

amrith501Option: B
Jun 12, 2022

Modules do not inherit variables from the parent module

Ni33Option: A
May 9, 2023

I think A is the correct answer. Variable value assignments can be passed from root module variables to child module.

cracitOption: B
Jun 7, 2023

Modules do not inherit variables from the parent module. All modules are self-contained units. So you have to explicitly define variables in the child module, and then explicit set these variables in the parent module, when you instantiate the child module.

modarovOption: B
Aug 5, 2023

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