My current setup has several decoupled modules.
Sometimes, I need to create a resource in module
foo which depends on module
However, since foo and bar are decoupled, I cannot create the dependency because they are unaware of each other’s existence.
I know that one can instantiate a module inside another one as a child module. But the problem is that this would also instantiate everything inside the child module.
To give an example of my setup:
-root --foo ---main.tf --bar ---main.tf --deploy ---main.tf (instantiates both foo and bar as child modules)
Inside of bar.main.tf there is a module definition that should depend on another one in foo.main.tf.
I cannot instantiate foo.main.tf inside bar.main.tf because it will then instantiate everything inside foo.main.tf, which should only happen inside deploy.main.tf.
But that also means that I cannot establish a dependency. Is there a way to work around this?