Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.
You have declared an input variable called environment in your parent module. What must you do to pass the value to a child module in the configuration?
A.
Add node_count = var.node_count
B.
Declare the variable in a terraform.tfvars file
C.
Declare a node_count input variable for child module
D.
Nothing, child modules inherit variables of parent module
C is correct as the question is about passing a variable. So if you want the parent to pass its output to its child you need to configure an input variable for that.
The name of the input variable makes no sense but maybe that is to emphasize on the fact that the name of the input variable is arbitrary.
"That module may call other modules and connect them together by passing output values from one to input values of another."
https://www.terraform.io/language/modules/develop
All given options are wrong, they don't make any sense
You have declared a variable called "environment"
A. where did you get the var.node_count, is it related to the question?
B. You can do that, but it is not what you need for the question
C. Then what? node_count variable should accept number, not a string. Assuming "environment" variable will hold string value like Dev, UAT, Prod
D. Child module will not automatically inherit variables from parent module
They don't make any sense
C. Declare a node_count input variable for child module.
When you declare an input variable in a parent module, the child module will not automatically inherit the value of the variable. You must explicitly declare the variable in the child module.
C. Declare a node_count input variable for the child module.
In Terraform, input variables are used to parameterize Terraform configurations. When using child modules, it is necessary to pass values for the input variables defined in the child module. The values for the input variables can be passed using different methods such as using default values, command-line flags, environment variables, variable files, and so on.
C. Declare a node_count input variable for child module.
When passing variables from a parent module to a child module in Terraform, you need to explicitly declare the variables in both the parent and the child modules. In this case, you would need to declare an input variable for the child module that corresponds to the input variable declared in the parent module. So, the correct option is C.
Option A is incorrect because it is using an example variable that is not related to the input variable mentioned in the question. Option B is incorrect because it refers to how to set the value of the variable, but not how to pass the value from the parent to the child module. Option D is also incorrect because child modules do not automatically inherit the variables of their parent modules.
C - correct
for every variable used in terraform module (root/child) you must first declare it.
Without declaration in child module the variable will not be recognized.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
tbhtp
Highly Voted 1 year, 10 months agoTyler2023
Highly Voted 8 months, 1 week ago7b5b962
Most Recent 2 weeks, 5 days agoTigerInTheCloud
6 months, 3 weeks agoarunrkaushik
11 months agomodarov
11 months, 1 week agomilan92stankovic
1 year agoNunyabiznes
1 year, 3 months agocamps
1 year, 3 months agothor7
1 year, 3 months agopyro7
1 year, 4 months agogekkehenk
1 year, 5 months agoDerekKey
1 year, 7 months agorobertninho
1 year, 6 months agoyogishrb2020
1 year, 9 months agonani1709
1 year, 9 months agoLinus11
1 year, 9 months agodonathon
1 year, 10 months agotbhtp
1 year, 10 months ago