From c618f89b6ee6d51bf71729af2adbcb4d85900883 Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Thu, 18 Jan 2024 15:11:18 +0100 Subject: [PATCH] feat(terraform: `azure-jenkinsinfra-controller`) allow DNS to use distinct provider or to be undefined (#135) * fix(terraform: azure-jenkinsinfra-controller) do not create DNS records when the DNS Zone name is unspecified Signed-off-by: Damien Duportal * feat(terraform: azure-jenkinsinfra-controller) allow different providers Signed-off-by: Damien Duportal --------- Signed-off-by: Damien Duportal --- terraform/modules/azure-jenkinsinfra-controller/main.tf | 6 ++++-- .../modules/azure-jenkinsinfra-controller/providers.tf | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/terraform/modules/azure-jenkinsinfra-controller/main.tf b/terraform/modules/azure-jenkinsinfra-controller/main.tf index 05bc886..112face 100644 --- a/terraform/modules/azure-jenkinsinfra-controller/main.tf +++ b/terraform/modules/azure-jenkinsinfra-controller/main.tf @@ -39,7 +39,8 @@ resource "azurerm_management_lock" "controller_publicip" { notes = "Locked because this is a sensitive resource that should not be removed" } resource "azurerm_dns_a_record" "controller" { - count = var.is_public ? 1 : 0 + count = var.is_public && var.dns_zone_name != "" ? 1 : 0 + provider = azurerm.dns name = trimsuffix(trimsuffix(local.controller_fqdn, var.dns_zone), ".") zone_name = var.dns_zone_name resource_group_name = var.dns_resourcegroup_name @@ -48,7 +49,8 @@ resource "azurerm_dns_a_record" "controller" { tags = var.default_tags } resource "azurerm_dns_a_record" "private_controller" { - count = var.is_public ? 1 : 0 + count = var.is_public && var.dns_zone_name != "" ? 1 : 0 + provider = azurerm.dns name = "private.${azurerm_dns_a_record.controller[0].name}" zone_name = var.dns_zone_name resource_group_name = var.dns_resourcegroup_name diff --git a/terraform/modules/azure-jenkinsinfra-controller/providers.tf b/terraform/modules/azure-jenkinsinfra-controller/providers.tf index ddf01e5..43e0135 100644 --- a/terraform/modules/azure-jenkinsinfra-controller/providers.tf +++ b/terraform/modules/azure-jenkinsinfra-controller/providers.tf @@ -1,7 +1,8 @@ terraform { required_providers { azurerm = { - source = "hashicorp/azurerm" + source = "hashicorp/azurerm" + configuration_aliases = [azurerm.dns] } azuread = { source = "hashicorp/azuread"