From 7a9b270092cf6655536f37eb3df5015f10554818 Mon Sep 17 00:00:00 2001 From: mclacore Date: Tue, 6 Feb 2024 14:22:14 -0800 Subject: [PATCH] Adding k8s-external-dns-azure multiple DNS zone support --- k8s-external-dns-azure/iam.tf | 4 +++- k8s-external-dns-azure/main.tf | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/k8s-external-dns-azure/iam.tf b/k8s-external-dns-azure/iam.tf index 47e3a270..31fef9df 100644 --- a/k8s-external-dns-azure/iam.tf +++ b/k8s-external-dns-azure/iam.tf @@ -29,8 +29,10 @@ resource "azurerm_role_assignment" "external_dns" { } resource "kubernetes_secret" "external_dns" { + for_each = { for zone in var.azure_dns_zones.dns_zones : zone => zone } + metadata { - name = "external-dns-auth" + name = "external-dns-auth-${each.value}" namespace = var.namespace labels = var.md_metadata.default_tags } diff --git a/k8s-external-dns-azure/main.tf b/k8s-external-dns-azure/main.tf index 031e0c1e..51e2cc8c 100644 --- a/k8s-external-dns-azure/main.tf +++ b/k8s-external-dns-azure/main.tf @@ -1,15 +1,16 @@ module "external-dns" { + for_each = { for zone in var.azure_dns_zones.dns_zones : zone => zone } source = "../k8s-external-dns" md_metadata = var.md_metadata kubernetes_cluster = var.kubernetes_cluster - release = var.release + release = regex("^[a-z0-9-]+", "${var.release}-${each.value}") namespace = var.namespace domain_filters = local.domain_filters helm_additional_values = { extraVolumes = [{ name = "azure-config-file" secret = { - secretName = kubernetes_secret.external_dns.metadata[0].name + secretName = kubernetes_secret.external_dns[each.key].metadata[0].name items = [{ key = "azure.json" path = "azure.json"