How would you output returned values from a child module?

Prepare for the HashiCorp Terraform Associate Exam. Utilize flashcards and multiple-choice questions with detailed hints and explanations. Boost your confidence and be ready for success!

Multiple Choice

How would you output returned values from a child module?

Explanation:
To share data from a child module, define output blocks inside the child module. These outputs expose the values the child produces so the caller (the root module) can access them via module.<child_name>.<output_name>. This is how data flows from a child to its parent. If you only declare outputs in the root, there’s nothing for the root to reference unless the child itself exposes an output, so the values from the child wouldn’t be available. Declaring outputs in both places is unnecessary unless you specifically want to surface the value at the root for users. So the standard and correct approach is to declare the output in the child module.

To share data from a child module, define output blocks inside the child module. These outputs expose the values the child produces so the caller (the root module) can access them via module... This is how data flows from a child to its parent. If you only declare outputs in the root, there’s nothing for the root to reference unless the child itself exposes an output, so the values from the child wouldn’t be available. Declaring outputs in both places is unnecessary unless you specifically want to surface the value at the root for users. So the standard and correct approach is to declare the output in the child module.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy