Skip to content

Instantly share code, notes, and snippets.

@calexandre
Last active December 19, 2022 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calexandre/61607a50411385321a55268ded902bb4 to your computer and use it in GitHub Desktop.
Save calexandre/61607a50411385321a55268ded902bb4 to your computer and use it in GitHub Desktop.
azurerm-find-private-endpoint-zones.tf
locals {
azurerm_private_endpoint = {
custom_dns_configs = [
{
"fqdn" = "something.westeurope.data.azurecr.io"
"ip_addresses" = [
"10.10.10.202"
]
},
{
"fqdn" = "something.azurecr.io"
"ip_addresses" = [
"10.10.10.204"
]
},
]
}
fqdn_ips = {for k,v in local.azurerm_private_endpoint.custom_dns_configs : v.fqdn => v.ip_addresses }
records_to_create = local.fqdn_ips["something.azurecr.io"]
}
output "fqdn_ips" {
value = local.fqdn_ips
}
output "records_to_create" {
value = local.records_to_create
}
@marconsilva
Copy link

Hello @calexandre

I was trying this out but with no success still...
Running your sample (adapted to my scenario) I got the following result

> {for k,v in azurerm_private_endpoint.acr_private_endpoint_ne.custom_dns_configs : v.fqdn => v.ip_addresses }

{
  "acrmydevne.azurecr.io" = tolist([
    "10.XXX.XXX.201",
  ])
  "acrmydevne.northeurope.data.azurecr.io" = tolist([
    "10.XXX.XXX.200",
  ])
}

the tolist() function appears here like a string... this makes the value a string and not a list...

> ({for k,v in azurerm_private_endpoint.acr_private_endpoint_ne.custom_dns_configs : v.fqdn => v.ip_addresses })["acrmydevne.azurecr.io"]

tolist([
  "10.158.85.201",
])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment