From 0da31ed235e32fcac451c996b39ea05cf8fe49d3 Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Thu, 18 Jan 2024 11:30:15 +0100 Subject: [PATCH 1/2] fix(terraform: azure-jenkinsinfra-controller) do not create DNS records when the DNS Zone name is unspecified Signed-off-by: Damien Duportal --- terraform/modules/azure-jenkinsinfra-controller/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/modules/azure-jenkinsinfra-controller/main.tf b/terraform/modules/azure-jenkinsinfra-controller/main.tf index 05bc886..abd3ac1 100644 --- a/terraform/modules/azure-jenkinsinfra-controller/main.tf +++ b/terraform/modules/azure-jenkinsinfra-controller/main.tf @@ -39,7 +39,7 @@ 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 name = trimsuffix(trimsuffix(local.controller_fqdn, var.dns_zone), ".") zone_name = var.dns_zone_name resource_group_name = var.dns_resourcegroup_name @@ -48,7 +48,7 @@ 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 name = "private.${azurerm_dns_a_record.controller[0].name}" zone_name = var.dns_zone_name resource_group_name = var.dns_resourcegroup_name From 177a9dec6622c55e0b0e90940db1eaa09bbadb20 Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Thu, 18 Jan 2024 14:15:59 +0100 Subject: [PATCH 2/2] feat(terraform: azure-jenkinsinfra-controller) allow different providers Signed-off-by: Damien Duportal --- terraform/modules/azure-jenkinsinfra-controller/main.tf | 2 ++ terraform/modules/azure-jenkinsinfra-controller/providers.tf | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/terraform/modules/azure-jenkinsinfra-controller/main.tf b/terraform/modules/azure-jenkinsinfra-controller/main.tf index abd3ac1..112face 100644 --- a/terraform/modules/azure-jenkinsinfra-controller/main.tf +++ b/terraform/modules/azure-jenkinsinfra-controller/main.tf @@ -40,6 +40,7 @@ resource "azurerm_management_lock" "controller_publicip" { } resource "azurerm_dns_a_record" "controller" { 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 @@ -49,6 +50,7 @@ resource "azurerm_dns_a_record" "controller" { } resource "azurerm_dns_a_record" "private_controller" { 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"