Terraform how to to reference module output in another module, getting 'Invalid reference' scenarios
I'm stuck on something that should probably be simple... I've searched everywhere and can't find a clear answer. I'm working on a project and hit a roadblock. I'm trying to set up a Terraform configuration where I want to reference an output from one module in another module, but I'm running into an 'Invalid reference' behavior. I have two modules: `network` and `instances`. In the `network` module, I'm outputting the VPC ID like so: ```hcl output "vpc_id" { value = aws_vpc.main.id } ``` In my root configuration file, I am using the `network` module as follows: ```hcl module "network" { source = "./modules/network" } ``` Then, in my `instances` module, I’m trying to access the VPC ID like this: ```hcl resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" vpc_security_group_ids = [module.network.vpc_id] } ``` However, when I run `terraform plan`, I get the following behavior: ``` behavior: Invalid reference on instances/main.tf line 5, in resource "aws_instance" "example": 5: vpc_security_group_ids = [module.network.vpc_id] A module output can only be accessed from the root module, or from the module that declares it. ``` I’ve double-checked that the output in the `network` module is declared correctly and that `instances` is indeed a sibling of `network`. I am unsure how to properly reference the output from the `network` module in the `instances` module. Any idea how to fix this? Also, I'm using Terraform version 1.4.6. How would you solve this? My development environment is macOS. Is there a better approach? For context: I'm using Hcl on Windows 10. Am I missing something obvious?