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

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 283 discussion

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

How would you output returned values from a child module in the Terraform CLI output?

  • A. Declare the output in the root configuration
  • B. Declare the output in the child module
  • C. Declare the output in both the root and child module
  • D. None of the above
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
nicecurls
Highly Voted 1 year, 2 months ago
Selected Answer: C
Answer C The question asks how to output the value in the cli, if we declare output only in a child module it will not be shown in the cli, we need one more output in the root configuration
upvoted 8 times
shanx910
1 year ago
100 % you are correct
upvoted 1 times
...
...
bella
Most Recent 5 months, 3 weeks ago
this question is a replica of question 232. Answer given was B. Declare the output in the child module.
upvoted 1 times
...
Newuser95
9 months ago
Selected Answer: B
n a parent module, outputs of child modules are available in expressions as module.<MODULE NAME>.<OUTPUT NAME>. For example, if a child module named web_server declared an output named instance_ip_addr, you could access that value as module.web_server.instance_ip_addr
upvoted 1 times
...
alen995454
10 months, 1 week ago
Selected Answer: C
Looked this up on another testing engine ( O'Reilly ) and it has "C" as the correct answer.
upvoted 2 times
...
kareem_ashraf
12 months ago
question is weird.. If both in C become any it would be C
upvoted 1 times
...
Tronko86
1 year ago
Selected Answer: C
C is correct. child>parent and parent>CLI
upvoted 2 times
...
3cc17f1
1 year, 1 month ago
Selected Answer: C
C is correct. To print to the CLI it will also need to be declared in the root config
upvoted 1 times
...
Tire
1 year, 1 month ago
Selected Answer: B
There is no need to set the output in the root module.
upvoted 1 times
...
enc_0343
1 year, 1 month ago
Selected Answer: C
You can use outputs.tf in the child module and the output block in the root module.
upvoted 1 times
...
BaburTurk
1 year, 2 months ago
B. Declare the output in the child module. To output returned values from a child module in the Terraform CLI output, you need to declare the output in the child module. Option A, declaring the output in the root configuration, is incorrect because the output is defined in the child module. Option C, declaring the output in both the root and child module, is also incorrect because this would create duplicate outputs. Option D, none of the above, is incorrect because there is a way to output returned values from a child module in the Terraform CLI output.
upvoted 3 times
Misiek
1 year, 2 months ago
A child module can use outputs to expose a subset of its resource attributes to a parent module. A root module can use outputs to print certain values in the CLI output after running terraform apply .
upvoted 2 times
...
...
RonZhong
1 year, 3 months ago
Selected Answer: C
1. To pass a value from child module to parent module, it must declare the output variable in child module. 2. To print out a value, it must declare the output variable in parent module.
upvoted 3 times
...
akm_1010
1 year, 3 months ago
Selected Answer: C
to output returned values from a child module to CLI - Declare the output in both the root and child module. For example: child-module.tf output "child_foo" { value = "foobar" } main.tf module "child" { source = "path/to/child" } output "output_to_cli" { value = module.child.child_foo }
upvoted 3 times
...
Rajmane
1 year, 3 months ago
Selected Answer: B
B is correct answer
upvoted 3 times
...
ShakDaddy
1 year, 3 months ago
Selected Answer: B
In a parent module, outputs of child modules are available in expressions as module.<MODULE NAME>.<OUTPUT NAME>. For example, if a child module named web_server declared an output named instance_ip_addr, you could access that value as module.web_server.instance_ip_addr.
upvoted 3 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 ...