Resource dependancy

Hii community required help in one usecase. Want to create module dependancy as well as resource dependancy.
For example,
I have created modules for each resource and saved in terraform private module registery. And refferencing it in module block using source parameter. In module I have for_each for every resource. I want some ways to create dependancy on resource from different module.

Suppose I’m creating two resource groups using rg module named as prod-rg and dev-rg using for_each. Now I want to create separate two virtual network for each rg. So
In module Vnet:

Module “vnet” {
For_each = var.vnet
source= "private-registry/Vnet

Similar to above script I want to refference exact prod rg created earlier but with dynamic variable . Like my next iteration will be for dev and it should map to dev rg.

It’s a real life scenario where we require smart mapping of resources to create dynamic dependency of exact resources to use it later.

Thank you in advance . Please suggest if your using some different methodology to overcome this issue.