Exam Terraform-Associate-004 Topic 3 Question 299 Discussion

Actual exam question for HashiCorp's Terraform-Associate-004 exam
Question #: 299
Topic #: 3
Exhibit:
resource "aws_instance" "example" {
ami = "ami-0a123456789abcdef"
instance_type = "t3.micro"
}
You are updating a child module with the resource block shown in the exhibit. The public_ip attribute of the resource needs to be accessible to the parent module. How do you meet this requirement?

Suggested Answer: A Vote an answer

Rationale for Correct answer: To expose values from a child module to a parent module, you define an output in the child module (e.g., output "public_ip" { value = aws_instance.example.public_ip }). The parent module can then reference it via module.<child_name>.public_ip.
Analysis of Incorrect Options (Distractors):
B: A data source in the parent could look up an instance, but that's unnecessary and brittle compared to using module outputs (and may require extra identifiers).
C: Import is for bringing existing resources into state; it doesn't expose attributes between modules.
D: Locals are only scoped within the module; they are not accessible from the parent.
Key Concept: Module composition: outputs are the contract for passing data from child to parent.

by Peter at May 06, 2026, 08:12 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
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.

0
0
0
10