Working with for_each for outputs in modules

Hello, I have a terraform module for azure load balancers. With AZLBs you create backend address pool that you have to pass to another resource called azurerm_network_interface_backend_address_pool_association to join VMs/Scalesets, etc to. in our LB module we allow multiple back end pools to be created. my problem is I can't seem to get the outputs of the backend address pool to pass to the backend address pool association. Below is my code, we are using for_each but can't seem to figure out the syntax issue. variable "backends" { default = ["BackendAddressPool1"] } resource azurerm_private_dns_zone private_dns { for_each = var.private_dns_zones name = each.value resource_group_name = module.rg.resource_group_name tags = var.tags # lifecycle { # ignore_changes = all # } } output "backend_address_pools_id" { description = "the id for the azurerm_lb_backend_address_pool resource" value = azurerm_lb_backend_address_pool.azlb[*].id } 

I get no values returned when I try to do this. usually there would only be 1 backend address pool but we want the flexibility to have more than one.

I've tried to look up numerous articles and understand how to return the right value from a for_each but I'm missing a concept for sure. Thank you for the help in advance.

submitted by /u/jblaaa
[link] [comments]

Read more here:

Content Attribution

This content was originally published by /u/jblaaa at Terraform, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: