I have created availability set (3 Vm) using terraform. Created one load balancer and trying to add internal IPs in load balancer pool, but doing something wrong so it creates 3 load balancer backend pool and add all VM internal ip in it. How can I create one load balancer backend pool and associated created ip of VM's to it.
Current Code :
resource "azurerm_network_interface_backend_address_pool_association" "tf" {
count = 3
network_interface_id = "${element(azurerm_network_interface.tf-nic.*.id, count.index)}"
ip_configuration_name = "app-vm-${count.index}-nic"
backend_address_pool_id = azurerm_lb_backend_address_pool.tf.id
}
I tried this code also, but it it won't work in my case
resource "azurerm_lb_backend_address_pool_address" "tf" {
name = "lb-bepool-address-${var.resource_postfix}"
backend_address_pool_id = azurerm_lb_backend_address_pool.tf.id
virtual_network_id = azurerm_virtual_network.tf.id
#ip_address = "${element(azurerm_virtual_machine.tf.*.private_ip_address, count.index)}"
#ip_address = "${element(azurerm_network_interface.tf-nic.*.private_ip_address, count.index)}"
}