# Calling variables and values from other modules

**URL:** <https://discuss.hashicorp.com/t/calling-variables-and-values-from-other-modules/21915>\
**Category:** Terraform\
**Created:** [March 10, 2021, 10:06pm UTC](https://discuss.hashicorp.com/t/calling-variables-and-values-from-other-modules/21915 "2021-03-10T22:06:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevenjw0228001](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/stevenjw0228001/32/6911_2.png) [@stevenjw0228001](https://discuss.hashicorp.com/u/stevenjw0228001)\
**Post date:** [March 10, 2021, 10:06pm UTC](https://discuss.hashicorp.com/t/calling-variables-and-values-from-other-modules/21915/1 "2021-03-10T22:06:42Z")

</div>

I am trying to deploy a vpc followed by an aws\_instance and cannot figure out how to pull the subnets created from the vpc module and get that data into the instance module. How do you achieve this?

---

<div class="post-metadata">

**Author:** ![ohmer](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ohmer/32/17491_2.png) [@ohmer](https://discuss.hashicorp.com/u/ohmer)\
**Post date:** [March 11, 2021, 8:48pm UTC](https://discuss.hashicorp.com/t/calling-variables-and-values-from-other-modules/21915/2 "2021-03-11T20:48:32Z")

</div>

The VPC module must be output’ing value that you can pass to your instance module or resource.

Example here: [Use Modules from the Registry | Terraform - HashiCorp Learn](https://learn.hashicorp.com/tutorials/terraform/module-use?in=terraform/modules#create-terraform-configuration)

---

<div class="post-metadata">

**Author:** ![stevenjw0228001](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/stevenjw0228001/32/6911_2.png) [@stevenjw0228001](https://discuss.hashicorp.com/u/stevenjw0228001)\
**Post date:** [March 12, 2021, 1:48pm UTC](https://discuss.hashicorp.com/t/calling-variables-and-values-from-other-modules/21915/3 "2021-03-12T13:48:36Z")

</div>

Ah. So if I have a networking module defining my private subnets, I would then have to set an output within that networking.tf module code like so?

output “subnet\_id\_private” {  
value = aws\_subnet.private\_subnet[\*].id  
}

Then I can pass that value to another module by using:

blah = module.moduleName.outputName
