Terraform Modules Explained: Why Root and Child Modules Cannot See Each Other

One of the most confusing behaviors in Terraform appears when a child module tries to access something defined in the root module and fails.

At first glance, everything exists in the same project. Same files. Same provider. Same environment.

So why does Terraform act like those resources do not exist?

The answer is not about files. It is about scope.

Terraform isolates every module into its own execution boundary.
A child module does not see the root module unless the root explicitly passes data into it.

This is why inputs and outputs exist.
They are not just for organization. They are the only legal path for data to move between modules.

Even more subtle is provider behavior.

A child module can use the same AWS provider as the root module.
It can create resources in the same account and region.

But it still cannot reference root resources by name.

Provider access does not equal scope access.

This distinction is what keeps Terraform plans deterministic.
Without it, hidden dependencies would make infrastructure unpredictable and unsafe to change.

Once you understand this boundary, module design becomes intentional instead of accidental.

And that is when Terraform starts behaving exactly as expected.

https://youtu.be/d5SM89wcUcg