Following are the steps that should be followed for making an object of one module to be available for the other module at a high level:
First, an output variable to be defined in a resource configuration. Till you do not declare resource configuration details, the scope of local and to a module.
Now, you have to declare the output variable of module_A to be used in other module’s configuration. A brand new and latest key name should be created by you and the value should be kept equivalent to the module_A’s output variable.
Now, for module_B you have to create a file variable.tf. Establish an input variable inside this file having exactly the same name as was in the key defined by you in module_B. In a module, this particular variable enables the resource’s dynamic configuration. For making this variable available to some other module also, replicate the process. This is because the particular variable established here have its scope restricted to module_B.