Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 112


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

Show Answer
Correct Answer: B

A module cannot always refer to all variables declared in its parent module. In order for a child module to access any variable from its parent module, that variable must be explicitly passed to the child module as an input variable. This is to ensure encapsulation and modularization, adhering to the principle of least privilege. Thus, it is false to say that a module can always refer to all variables in its parent module without explicit declaration and passing of inputs.

Discussion

21 comments
Sign in to comment
BurakkoOption: B
Sep 1, 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.

Burakko
Sep 2, 2023

However you can refer them from the parent module, I guess it is A. The question is asking for referring not inheriting.

kiran15789Option: B
May 13, 2024

A module in Terraform can only access variables that are explicitly passed as input variables or declared as outputs by the parent module. It cannot access variables declared within the parent module unless they are passed to the module as input variables. This is known as the "principle of least privilege," which means that modules should only have access to the information and resources that they need to perform their tasks, and no more. So, to refer to a variable from a parent module, you must either pass it as an input variable to the child module or declare it as an output variable in the parent module and then reference it in the child module using the module.<name>.<output> syntax.

Tyler2023
Nov 3, 2024

Answer is A

Tyler2023
Nov 3, 2024

The question is asking if we can always refer to all variables declared which is true, It is not asking if it is automatically or manually

Tyler2023
Nov 3, 2024

Answer is A

raf314Option: B
Apr 25, 2024

The question is whether a (child) module can always refer to ALL variables in the parent module. The answer is NO. The child module can "see" and refer to the variables defined in its own (child module's) definition. The child module has no visibility of the variables defined in the parent module. Thus it cannot refer to them. Answer is False (B)

InformationOverloadOption: A
Jan 2, 2024

I says refer, not inherit. I go with A

milan92stankovicOption: A
Jun 15, 2024

The answer is A. You CAN always REFER. You don't have to, but you can.

seif1993Option: A
Dec 8, 2023

A is correct ans

wanrltw
Dec 9, 2023

Definitely A. Source: trust me, bro

DemonikOption: A
Nov 29, 2024

A for me

Vish12345678Option: A
Dec 4, 2023

A is correct ans

agmesasOption: B
Feb 7, 2024

B you must declare the variable in the child module if you can use it. Also, the parent module must call the child module using inputs. First, the parent module declares variables, second, the child module declares its inputs, then, the parent module call to the child module using inputs that were declared in the variables.tf of the child module.

BennaniHaythem
Apr 17, 2024

A module can refer to variables in its parent module only if those variables are explicitly passed to it as input variables. If a variable is not passed to a child module, then that child module cannot refer to it. So the correct answer is B - False.

ssanjaytOption: A
Jan 13, 2024

A is correct !A module can always refer to all variables declared in its parent module

campsOption: B
Mar 31, 2024

False. A module can refer to variables in its parent module only if they are explicitly passed to it using variable definitions or module blocks in the calling module.

Stargazer11
Nov 2, 2024

Answer: B A child module can refer to variables declared in its parent module, but it does so in a controlled and explicit manner. By default, child modules do not have automatic access to all variables in the parent module. To reference a variable from the parent module in a child module, you should declare an input variable with the same name in the child module and then explicitly pass the value from the parent module.

Zeppoonstream
Jan 20, 2024

A. True. A module in Terraform can always refer to all variables declared in its parent module, as long as the parent module is called before the child module in the configuration file.

rotimislawOption: A
Feb 24, 2024

Seems A to me

phidelicsOption: A
Mar 23, 2024

refer to* key word i guess

NunyabiznesOption: B
Mar 27, 2024

B. False A module can only refer to variables that are explicitly passed to it as inputs, either through variable declarations or module calls. It cannot automatically refer to all variables declared in its parent module, as it may not need or have access to all of them. If a variable is not passed to a module as an input, the module will not be able to use it directly.

Sathisgm
Apr 13, 2024

True we can refer parent module

sylvergorillaOption: B
Apr 14, 2024

No, a module cannot always refer to all variables declared in its parent module. Only variables declared as public in the parent module can be referred to by a module.

Ni33Option: B
May 9, 2024

B is the correct answer