Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

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.

Exam Terraform Associate topic 1 question 100 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 100
Topic #: 1
[All Terraform Associate Questions]

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
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
tbhtp
Highly Voted 1 year, 10 months ago
Selected Answer: C
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
upvoted 21 times
...
Tyler2023
Highly Voted 8 months, 1 week ago
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
upvoted 9 times
...
7b5b962
Most Recent 2 weeks, 5 days ago
module "child_module" { source = "./path_to_child_module" environment = var.environment } Therefore, the correct answer is: A. Add node_count = var.node_count
upvoted 1 times
...
TigerInTheCloud
6 months, 3 weeks ago
Selected Answer: A
You need to pass the value. (The child module should have the variable, that the child module developer's work)
upvoted 1 times
...
arunrkaushik
11 months ago
Mr. Nunyabusines, may you like to rewrite the answer as: module "child_module" { source = "./parent_module" environment = var.environment }
upvoted 3 times
...
modarov
11 months, 1 week ago
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.
upvoted 3 times
...
milan92stankovic
1 year ago
Selected Answer: C
I vote for C
upvoted 1 times
...
Nunyabiznes
1 year, 3 months ago
Selected Answer: C
module "child_module" { source = "./child_module" environment = var.environment }
upvoted 4 times
...
camps
1 year, 3 months ago
Selected Answer: C
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.
upvoted 1 times
...
thor7
1 year, 3 months ago
Selected Answer: C
https://www.terraform.io/language/modules/develop C is a correct answer
upvoted 1 times
...
pyro7
1 year, 4 months ago
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.
upvoted 3 times
...
gekkehenk
1 year, 5 months ago
Selected Answer: C
C, declaration of variables is not done in terraform.tfvars.
upvoted 2 times
...
DerekKey
1 year, 7 months ago
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.
upvoted 2 times
robertninho
1 year, 6 months ago
# Parent module module "child" { source = "./child" node_count = var.environment } # Child module variable "node_count" { type = number }
upvoted 7 times
...
...
yogishrb2020
1 year, 9 months ago
Selected Answer: C
Declare the variable in a terraform.tfvars file --> doesnot apply to child module -->https://www.terraform.io/language/values/variables
upvoted 2 times
...
nani1709
1 year, 9 months ago
A is the correct answer.
upvoted 1 times
...
Linus11
1 year, 9 months ago
Searched in google " terraform node_count" no result. What is this node_count do?
upvoted 2 times
...
donathon
1 year, 10 months ago
Selected Answer: B
The answer is B. TFVARS is like a global variable.
upvoted 2 times
tbhtp
1 year, 10 months ago
B is not correct. Reading something from the same place is not passing a variable. Imagine what happens if the parent gets its value passed with -var.
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...
ex Want to SAVE BIG on Certification Exam Prep?
close
ex Unlock All Exams with ExamTopics Pro 75% Off
  • arrow Choose From 1000+ Exams
  • arrow Access to 10 Exams per Month
  • arrow PDF Format Available
  • arrow Inline Discussions
  • arrow No Captcha/Robot Checks
Limited Time Offer
Ends in