A root module declares output db_endpoint with value = module.database.endpoint. terraform plan fails with an Unsupported attribute error saying the module object has no attribute named endpoint. The child module creates the database instance but declares no outputs. What fixes it?
Select an answer to reveal the explanation.
Short Explanation
A module is a sealed box with labeled ports; outputs are the ports. If the child never cut a port called endpoint, you can't reach in and grab it. The trap is trying to reach through the box to the resource inside.
Full Explanation
Modules encapsulate their resources. A calling module can access only the values a child explicitly exports through output blocks, which appear as attributes of the module object, such as module.database.endpoint. Because the child declares no outputs, the module object has no attributes, and Terraform reports an unsupported attribute. Adding output "endpoint" { value = aws_db_instance.this.endpoint } in the child module defines the contract and makes the root reference valid. Addressing a resource inside a child module from the caller is not valid expression syntax; full resource addresses such as module.database.aws_db_instance.this are used by CLI commands like state show, not by configuration expressions. depends_on only orders operations and cannot add attributes to an object. terraform init installs modules and providers but does not change which values a module exposes, so re-running it leaves the error in place. Exam caveat: the same rule applies to nested modules; each layer must re-export a value with its own output for the next caller to see it. Operational check: after adding the output, run terraform plan and confirm the root output resolves, then run terraform output db_endpoint after apply.