Ideally, I originally wanted to output a list of self_link
for GCP in my terraform output, but can’t even get a simple string to work:
module "master-nodes" {
source = "./master-nodes"
network = google_compute_network.k3s.self_link
project = var.project
service_account = var.service_account
ssh = var.ssh
for_each = var.servers
name = each.key
subnet_name = each.key
region = each.value.region
cidr_range = each.value.cidr_range
machine_type = each.value.machine_type
}
module "networking" {
source = "./networking"
network = google_compute_network.k3s.self_link
instance_names = module.master-nodes.instance_names[*].name
}
I want to feed instance_names
into the networking
module after the compute resources have been created. Inside my master-nodes
modules, I have outputs defined like so:
output "instance_names" {
value = google_compute_instance.k3s-master.name
description = "The names of the instances created by the master-nodes module."
}
I’ve tried many variations of this:
output "instance_names" {
value = [ for compute in google_compute_instance.k3s-master.name: compute.name]
description = "The names of the instances created by the master-nodes module."
}
output "instance_names" {
value = [for instance in module.master-nodes : instance.name]
description = "The names of the instances created by the master-nodes module."
}
Nothing works. How should I set this up?