PaloAltoNetworks / terraform-azurerm-swfw-modules

Terraform Reusable Modules for Software Firewalls on Azure
https://registry.terraform.io/modules/PaloAltoNetworks/swfw-modules/azurerm
MIT License
5 stars 10 forks source link

Add support for custom dns servers in `vnet` sub-module #76

Closed jinkang23 closed 2 months ago

jinkang23 commented 3 months ago

Is your feature request related to a problem?

In our Azure environment, we utilize Azure DNS Private Resolver with inbound endpoints in a separate spoke VNET. The Hub NGFW Firewall's VNET by default is configured to point to the Default (Azure-provided) DNS servers. Although we can workaround this by setting the DNS servers via the azurerm_virtual_network_dns_servers resource outside of this module, I would like to see support for specifying custom DNS servers natively within this vnet sub-module.

Describe the solution you'd like

Add new optional variable to specify custom DNS servers and update azurerm_virtual_network resource to accept these values.


variable "dns_servers" {
  type = list(string)
  default = null
}

resource "azurerm_virtual_network" "this" {
  count = var.create_virtual_network ? 1 : 0

  name                = var.name
  location            = var.region
  resource_group_name = var.resource_group_name
  address_space       = var.address_space

  dns_servers         = var.dns_servers #<-- set the custom DNS server(s)

  tags                = var.tags

  dynamic "encryption" {
    for_each = var.vnet_encryption != null ? [1] : []
    content {
      enforcement = var.vnet_encryption
    }
  }

  lifecycle {
    precondition {
      condition     = length(coalesce(var.address_space, [])) > 0
      error_message = "The `var.address_space` property is required when creating a VNET."
    }
  }
}

Describe alternatives you've considered.

Use azurerm_virtual_network_dns_servers resource outside of this module.

Additional context

No response

acelebanski commented 2 months ago

Hi @jinkang23, thanks for raising this feature request. This will be added by PR #85 and should be released soon!