Hi all ,
I am trying to get the data source of network interface id dynamically as a variable and i want the code to iterate through the list and it should add itself to the backendpool association . I am able think of the below logic but am facing error like count can be used only when count argument is set , Please help me code is below
data "azurerm_network_interface" "example" {
count = length(var.nic_name)
name = var.nic_name[count.index]
resource_group_name = "networking"
}
resource "azurerm_network_interface_backend_address_pool_association" "example"
{
network_interface_id = data.azurerm_network_interface.example[count.index].id
ip_configuration_name = data.azurerm_network_interface.example[count.index].ip_configuration[0].name
backend_address_pool_id = azurerm_lb_backend_address_pool.example.id
}
variable "nic_name" {
type = list
default = [ "somenic1","somenic2"]
}