So, I have a terraform folder structure as follows:
environments
staging
gke
main.tf
terraform.tfvars
variables.tf
vpc
main.tf
terraform.tfvars
variables.tf
secrets.tfvars (non-versioned)
globals.tfvars
terraform.tfvars (terragrunt helps require secrets and globals)
modules
vpc
main.tf
outputs.tf
gke
main.tf
outputs.tf
The problem I have is that I don't know how to access for example the VPC module self link that I am setting as output, from the GKE module.
Every example I see has like a main.tf on the "staging" level where every module is called in the same file, so that way they can access modules output, but I don't have one (should I with my folder structure approach?)
Would by solution grab the value from remote state? I was trying to access it but it always says it doesn't find the resource:
// Define VPC
network = "${data.terraform_remote_state.vpc.main_vpc_self_link}"
I try to access like that this output I have in my VPC module (the module is called vpc)
// Self link to the VPC
output "main_vpc_self_link" {
value = "${google_compute_network.main_vpc_network.self_link}"
}