How to reference root module variable file to child module

Hi Team,

I am new to terraform and i unable to understand some concepts.

Question: How to reference root module variable file to child modules without creating multiple file in child module.

currently i am maintaining file for any variable reference. and i copied to all child modules to work properly but still it’s not working. hence please help me on this.
├── modules
│ ├── compute
│ │ ├──
│ │ └──
│ └── network
│ ├── firewall
│ │ ├──
│ │ └──
│ └── vpc
│ ├──
│ └──
└── setup
├── terraform.tfstate
└── terraform.tfstate.backup

Thanks in advance.

Every module is its own encapsulation of code, defining its own inputs and outputs – so if you want to pass data from the root module/variables in that space to child modules, you need to define input variables for those modules relevant to what that particular module needs – this helps make your modules fully encapsulated.

So the folder structure you have here seems like it works, except for those references to all_variable … each module seems to (and would) have its own inputs/outputs, so seeing the for example looks good to me.