I ended up with the following solution, which is exactly what I wanted, thank you so much @stuart-c !
locals {
instances = merge(
{
for id, info in var.runner_managers : "${var.runner_type}-runners-manager-${id}-blue" => info
if var.deployment.blue
},
{
for id, info in var.runner_managers : "${var.runner_type}-runners-manager-${id}-green" => info
if var.deployment.green
}
)
}
resource "google_compute_instance_from_template" "runners_manager" {
for_each = local.runners_manager.instances
name = each.key
zone = each.value.zone
}
Other resources I used to help me figure this out: