Using Module Outputs
The root module calls a child module with module "network" { source = "./modules/network" }. Inside it, the VPC is aws_vpc.main. How does the root module get the VPC ID?
module "network" { source = "./modules/network" }
aws_vpc.main
Choose one answer
Declare an output "vpc_id" in the child module and reference module.network.vpc_id in the root.
output "vpc_id"
module.network.vpc_id
Reference module.network.aws_vpc.main.id directly from the root module, since every resource in a child module is readable from its caller.
module.network.aws_vpc.main.id
Declare variable "vpc_id" in the root; Terraform fills it from the child.
variable "vpc_id"
Add a data "terraform_module" "network" block and read its vpc_id.
data "terraform_module" "network"
vpc_id