I want to add multiple ip addresses to configure access restrictions in azure for an app service and also this should be accomplished only for a few environments, I'm using the dynamic block to achieve this, it was working as long as there was only one IP, but now I want to allow more ip addresses, is there a way to achieve this?
dynamic "ip_restriction" {
for_each = var.ip_addresses
content {
ip_address = ip_restriction.value["ip_address"]
priority = ip_restriction.value["priority"]
name = ip_restriction.value["name"]
}
}
This works perfect but I want to add the environment restriction as well. something like
for_each = var.env == "dev" || var.env == "qa" ? [1] : []
CodePudding user response:
This works perfect but I want to add the environment restriction as well.
You are really close, you just need to change this array: [1]
to be the actual array of IP addresses, like so:
for_each = var.env == "dev" || var.env == "qa" ? var.ip_addresses : []