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
stalk98
Jun 8, 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.

Duleep
Jan 8, 2025

variable assignments is name = "ABC" // this is assignments and it will inherit and not need to define and assign again in child module variable "name" { type = string default = "t2.micro" # This is an optional default value. }

EltoothOption: B
Jul 6, 2023

B is correct answer : false.

DineshSG
May 17, 2024

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, 2024

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, 2023

Modules do not inherit variables from the parent module

Ni33Option: A
May 9, 2024

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

cracit
Jun 7, 2024

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.

modarov
Aug 5, 2024

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