Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 291


The Terraform CLI will print output values from a child module after running terraform apply.

Show Answer
Correct Answer: A

The Terraform CLI will print output values from a child module after running terraform apply. Outputs defined in the child module are propagated to the root module, and then the root module can display these values in the CLI output. This is part of how Terraform surfaces useful information after the configuration is applied.

Discussion

4 comments
Sign in to comment
Ramdi1Option: B
Nov 25, 2023

Output values have several uses: 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.

PolitoMexOption: B
Dec 1, 2023

child modules send outputs to root module and then the root module prints the outputs.

Stargazer11Option: A
Nov 27, 2023

True. Output values are stored in state file. Only after a terraform apply, it knows that there are values in state file. Running terraform output output_name results in warning Warning: No outputs found. The state file either has no outputs defined, or all the defined outputs are empty. Please define an output in your configuration with the `output` keyword and run `terraform refresh` for it to become available. If you are using interpolation, please verify the interpolated value is not empty. You can use the `terraform console` command to assist.

090200fOption: B
Aug 5, 2024

Accessing Child Module Outputs 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.

090200f
Aug 5, 2024

https://developer.hashicorp.com/terraform/language/values/outputs