Terraform 1.4.3: implementing Module Outputs Not Referencing Correct Variables in Nested Modules
Quick question that's been bugging me - I'm working with an scenario where the outputs from a nested module are not referencing the variables I expect, resulting in incorrect values being passed to the parent module. I'm using Terraform version 1.4.3 and have the following structure: ```hcl module "network" { source = "./modules/network" vpc_name = var.vpc_name } module "app" { source = "./modules/app" subnet_id = module.network.subnet_id } ``` In my `network` module, I define the subnet output like this: ```hcl output "subnet_id" { value = aws_subnet.main.id } ``` However, in the `app` module, I'm trying to use the `subnet_id` output but getting an behavior: `behavior: Invalid reference: module.network.subnet_id is not a valid reference.`. I've checked that the `network` module is correctly defined, and it seems to be working as expected when I run `terraform output`. I have also tried explicitly defining outputs in the root module to pass them through, but the behavior continues. I'm worried that there might be a question with how Iām structuring the module outputs or the variable references themselves. Another thing I noticed is that if I try to directly access outputs within the same module, it works fine, but the question arises when I try to access it from another module. Any insights or suggestions on how to resolve this scenario would be greatly appreciated, especially if there are best practices for handling nested module outputs in Terraform. For reference, this is a production application. Any advice would be much appreciated.