Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 283


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

Show Answer
Correct Answer: C

To output returned values from a child module in the Terraform CLI output, you need to declare the output in both the child module and the root configuration. The child module declaration defines the output, while the root configuration references it, making it available for CLI output. This setup allows the root module to access and display the output values from the child module.

Discussion

14 comments
Sign in to comment
nicecurlsOption: C
Sep 5, 2023

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

shanx910
Nov 12, 2023

100 % you are correct

ShakDaddyOption: B
Aug 4, 2023

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.

RajmaneOption: B
Aug 11, 2023

B is correct answer

akm_1010Option: C
Aug 15, 2023

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 }

RonZhongOption: C
Aug 17, 2023

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.

BaburTurkOption: B
Aug 28, 2023

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.

Misiek
Sep 6, 2023

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 .

Tronko86Option: C
Nov 4, 2023

C is correct. child>parent and parent>CLI

alen995454Option: C
Jan 17, 2024

Looked this up on another testing engine ( O'Reilly ) and it has "C" as the correct answer.

enc_0343Option: C
Oct 4, 2023

You can use outputs.tf in the child module and the output block in the root module.

TireOption: B
Oct 8, 2023

There is no need to set the output in the root module.

3cc17f1Option: C
Oct 18, 2023

C is correct. To print to the CLI it will also need to be declared in the root config

kareem_ashrafOption: C
Nov 26, 2023

question is weird.. If both in C become any it would be C

Newuser95Option: B
Feb 20, 2024

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

bellaOption: B
May 30, 2024

this question is a replica of question 232. Answer given was B. Declare the output in the child module.