Skip to content

Commit

Permalink
feat(terraform: azure-jenkinsinfra-controller) allow DNS to use dis…
Browse files Browse the repository at this point in the history
…tinct 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 <[email protected]>

* feat(terraform: azure-jenkinsinfra-controller) allow different providers

Signed-off-by: Damien Duportal <[email protected]>

---------

Signed-off-by: Damien Duportal <[email protected]>
  • Loading branch information
dduportal authored Jan 18, 2024
1 parent d82a181 commit c618f89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions terraform/modules/azure-jenkinsinfra-controller/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion terraform/modules/azure-jenkinsinfra-controller/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
source = "hashicorp/azurerm"
configuration_aliases = [azurerm.dns]
}
azuread = {
source = "hashicorp/azuread"
Expand Down

0 comments on commit c618f89

Please sign in to comment.