Nesting loop with result of for_each

Thanks for your reply and suggestion. Indeed, there is more information in the list of instances, but not related to this part.

After a lot of time trying and battling the code, I finally managed to get this working. Might not be the nicest setup, but at least it does what I need :-).

First I create a local producing the the required output (thanks for that tip):

locals {
  # flatten ensures that this local is a flat list of objects, rather than a list of lists of objects.
  servers_services = flatten([
    for  server in module.server : [
      for service in var.services : {
        server_name   = server.name
        server_ip     = server.private_ip
        service_name  = service.name
        service_port  = service.port
      }
    ]
  ])
}

After that a loop to process each record in the local variable:

resource "oci_network_load_balancer_backend" "Backend" {
  for_each = {for i,v in local.servers_services: i=>v}
    backend_set_name         = "${each.value.service_name}"
    network_load_balancer_id = oci_network_load_balancer_network_load_balancer.services.id
    ip_address               = each.value.server_ip
    port                     = each.value.service_port
    name                     = "${each.value.server_name}_${each.value.service_port}"
}