Terraform Module scenarios to Reference Output from Another Module in Google Cloud
I'm working on a project and hit a roadblock. After trying multiple solutions online, I still can't figure this out. Hey everyone, I'm running into an issue that's driving me crazy. I'm running into an scenario where I'm trying to reference the output of one Terraform module in another module, specifically in Google Cloud. My current configuration looks like this: In my main `main.tf` file, I have: ```hcl module "network" { source = "./modules/network" } module "instance" { source = "./modules/instance" network_name = module.network.network_name } ``` In the `network` module, I have the following output defined: ```hcl output "network_name" { value = google_compute_network.my_network.name } ``` However, I'm getting the behavior: ``` behavior: Invalid reference on main.tf line 7, in module "instance": 7: network_name = module.network.network_name A module's outputs want to be referenced until the module has been applied. ``` I've double-checked that my `network` module is indeed creating a resource. To troubleshoot, I ran `terraform apply` on the `network` module alone, which successfully creates the network and outputs the name. I've also ensured that the output variable is correctly defined and returning a value. Is there a specific way I need to structure these modules to ensure that outputs can be referenced correctly? I've tried restructuring the code multiple ways and need to seem to get it to work. I'm using Terraform version 1.2.3. Any insight would be greatly appreciated. I'm working on a CLI tool that needs to handle this. Has anyone else encountered this? For context: I'm using Hcl on macOS. What am I doing wrong? This is part of a larger service I'm building. I'd really appreciate any guidance on this.