Referencing output of resource outside the module

So I’ve spent the last couple of days banging my head against this, and I’m hoping that someone can point me in the right direction. I’ve got an AWS VPC terraform module that works totally fine and I can use a parent module to call it and input the variables and all that jazz.

What I’m trying to do is take the output of specific modules (ex. aws_vpc.*.id amongst others) and reference/call them from another child module in the same directory.

Folder Structure:
|-- <- this works great with the VPC module
|— <- want to reference resource ID’s from this module
|— <- wanting to reuse said resources so I keep my code dry.

Any assistance would be greatly appreciated!

1 Like

Without seeing your code I’m only guessing, but if in ‘’ you are creating a module called ‘foo’ with source being ‘modules/VPC’, then in EC2’s Terraform file you’ll need to refer to outputs from the VPC module as<output name>.

Yep! I should’ve closed this, as I got it figured out. Thanks for responding!

1 Like