Is it possible to create a dependency on an external module?

My current setup has several decoupled modules.
Sometimes, I need to create a resource in module foo which depends on module bar.
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:

--deploy (instantiates both foo and bar as child modules)

Inside of there is a module definition that should depend on another one in

I cannot instantiate inside because it will then instantiate everything inside, which should only happen inside

But that also means that I cannot establish a dependency. Is there a way to work around this?

Hi @dasph21 ,

Not sure if this will help you. You could output a value of that you are interested to see in And within you could pass that as module input to That’ll create a dependency

so, within you could do this,

output "bar_uuid" {
 value = random_uuid.bar_uuid

And within

module "bar" {
  source = "../modules/bar"
module "foo" {
  source = "../modules/foo"
  bar_uuid =

That should create a dependency.
Apologies if I completely misunderstood your requirement.