From 152c172b55bbe87e370a5b7b6f1f64c1f6a8c5b7 Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Wed, 22 Apr 2020 15:43:48 +0200 Subject: [PATCH] fix DNS module internal zone lookup --- CHANGELOG.md | 2 ++ modules/dns/main.tf | 8 +++++--- modules/dns/outputs.tf | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 578007856..08704af7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- fix DNS module internal zone lookup + ## [1.3.0] - 2020-04-08 - add organization policy module diff --git a/modules/dns/main.tf b/modules/dns/main.tf index 4c9dfae21..6e098b8d8 100644 --- a/modules/dns/main.tf +++ b/modules/dns/main.tf @@ -20,9 +20,11 @@ locals { for record in var.recordsets : join("/", [record.name, record.type]) => record } - zone = element(concat( - google_dns_managed_zone.non-public, google_dns_managed_zone.public - ), 0) + zone = try( + google_dns_managed_zone.non-public.0, try( + google_dns_managed_zone.public.0, null + ) + ) } resource "google_dns_managed_zone" "non-public" { diff --git a/modules/dns/outputs.tf b/modules/dns/outputs.tf index df35628a2..87add7401 100644 --- a/modules/dns/outputs.tf +++ b/modules/dns/outputs.tf @@ -26,15 +26,15 @@ output "zone" { output "name" { description = "The DNS zone name." - value = local.zone.name + value = try(local.zone.name, null) } output "domain" { description = "The DNS zone domain." - value = local.zone.dns_name + value = try(local.zone.dns_name, null) } output "name_servers" { description = "The DNS zone name servers." - value = local.zone.name_servers + value = try(local.zone.name_servers, null) }