Hi ,
I’m ttrying to create public ips based on a list of names and assigme them to a load balancer but I’m stuk
Given a list of ips like [“ip1”, “ip2”…]
I use
resource "azurerm_public_ip" "myip" {
for_each = toset(var.ips)
name = "public-${each.key}"
location = var.location
resource_group_name = var.rg_name
allocation_method = "Static"
sku = "Standard"
}
resource "azurerm_lb" "loadbalancer" {
depends_on = [azurerm_public_ip.myip]
location = var.location
name = "myLoadBalancer"
resource_group_name = var.rg_name
sku = "Standard"
sku_tier = "Regional"
tags = {}
frontend_ip_configuration {
for_each = toset(var.ips)
name = "myFrontEnd-${each.key}}"
private_ip_address_allocation = "Dynamic"
public_ip_address_id = **??????**
zones = []
}
The problem is, at least, how to add the “correct” public_ip_address_id , that is public-ip1 to myFrontEnd-ip1 and so on