Skip to content

data-platform-hq/terraform-azurerm-private-dns

Repository files navigation

Azure Private DNS Terraform module

Terraform module for creation Azure Private DNS

Usage

This module provides an ability to provision Private DNS Zone and create link between Private DNS Zone and Virtual Network.

Example on creation of Private DNS Zone within module and linking Virtual Network to it:

data "azurerm_virtual_network" "example" {
  name                = "example_vnet"
  resource_group_name = "example_rg"
}

module "dns" {
  resource_group = "example_rg"
  dns_zone_name  = "privatelink.dfs.core.windows.net"
  vnet_map       = tomap({ 
    (data.azurerm_virtual_network.example.name) = data.azurerm_virtual_network.example.id
  })
  tags = { environment = "dev" }
}

Furthermore, it is possible to create link between already existing Private DNS Zone and Virtual Network, thus creating of new Private DNS Zone is actually optional.

data "azurerm_virtual_network" "example" {
  name                = "example_vnet"
  resource_group_name = "example_rg"
}

module "dns" {
  resource_group          = "example_rg"
  external_dns_zone_name  = "privatelink.azuredatabricks.net"
  vnet_map                = tomap({
    (data.azurerm_virtual_network.example.name) = data.azurerm_virtual_network.example.id
  })
  tags = { environment = "dev" }
}

Requirements

Name Version
terraform >= 1.0.0
azurerm >= 3.40.0

Providers

Name Version
azurerm >= 3.40.0

Modules

No modules.

Resources

Name Type
azurerm_private_dns_a_record.example resource
azurerm_private_dns_zone.this resource
azurerm_private_dns_zone_virtual_network_link.this resource

Inputs

Name Description Type Default Required
create_private_dns_zone Boolean flag that determines whether Private DNS Zones is created by this module bool true no
dns_zone_name The name of the Private DNS Zone that needs to be created or linked to the virtual network string n/a yes
private_dns_a_records List of objects with parameters to create A Record in Private DNS Zone
list(object({
name = string
ttl = optional(number, 300)
records = list(string)
}))
[] no
resource_group Resource group where Private DNS zone would be created or it is already exists string n/a yes
tags Resource tags map(string) {} no
vnet_map Map of Virtual Network Name to Id, used to create VNet Link to Private DNS map(string) {} no

Outputs

Name Description
id Private DNS Zone Id
name Private DNS Zone Name
resource_group Private DNS Zone Resource Group
vnet_link_name_to_id_map Map of Virtual Network Link names to it's ids

License

Apache 2 Licensed. For more information please see LICENSE