i have following code to create private endpoint, and if provided, will be associated with a private dns zone as well, however, the private endpoint is crated ignoring private dns zone value I entered, treat it as Null resource. I'm not sure what went wrong inside the dynamic block
resource "azurerm_private_endpoint" "this" {
name = join("", [lookup(var.service_subresource_map, "name"), "-pvt-endpoint"])
location = var.location
resource_group_name = var.resource_group_name
subnet_id = data.azurerm_subnet.endpoint_subnet.id
tags = var.tags
private_service_connection {
name = join("", [lookup(var.service_subresource_map, "name"), "-pvt-endpoint-conn"])
private_connection_resource_id = lookup(var.service_subresource_map, "resource_id")
subresource_names = [lookup(var.service_subresource_map, "subresource_name")]
is_manual_connection = false
}
dynamic "private_dns_zone_group" {
for_each = var.private_dns_zone_group[*]
content {
name = private_dns_zone_group.value.name
private_dns_zone_ids = private_dns_zone_group.value.private_dns_zone_ids
}
}
the value I provided in private_dns_zone_group is this
private_dns_zone_group = {
name = "private-dns-zone-group"
private_dns_zone_ids = [
"/subscriptions/xxx/resourceGroups/rogertest/providers/Microsoft.Network/privateDnsZones/example.com",
]
}
and variable is as following
variable "private_dns_zone_group" {
type = object({
name = string
private_dns_zone_ids = list(string)
})
default = null
}
everything is deployed without error except for private dns zone association
if I replace dynamic block with simple block like this
private_dns_zone_group {
name = "private-dns-zone-group"
private_dns_zone_ids = [
"/subscriptions/xxx/resourceGroups/rogertest/providers/Microsoft.Network/privateDnsZones/example.com",
]
}
then it works.