### Basic SOA Record Example Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_soa_record/_header.md This example demonstrates the most basic usage of the module for adding SOA records to an existing private DNS zone using for_each iteration. Ensure 'parent_id' and 'name' are provided. ```terraform locals { domain_name = "testlab.io" soa_record = { email = "hostmaster.${local.domain_name}" } } module "dns_soa_record" { source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_soa_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name tags = each.value.tags } ``` -------------------------------- ### Basic TXT Record Example Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_txt_record/_header.md This example demonstrates the most basic usage of the module for adding TXT records to an existing private DNS zone using for_each iteration. ```terraform locals { txt_records = { "txt_record1" = { name = "txt1" ttl = 300 records = { "txtrecordA" = { value = "apple" } "txtrecordB" = { value = "banana" } } tags = { "env" = "prod" } } "txt_record2" = { name = "txt2" ttl = 300 records = { "txtrecordC" = { value = "orange" } "txtrecordD" = { value = "durian" } } tags = { "env" = "prod" } } } } module "dns_txt_record" { for_each = local.txt_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_txt_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl records = each.value.records tags = each.value.tags } ``` -------------------------------- ### Basic A Record Example Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_a_record/_header.md This example demonstrates the basic usage of the private DNS A record module, creating multiple A records using for_each iteration. Ensure the parent_id is correctly set for your private DNS zone. ```terraform locals { a_records = { "record1" = { name = "my_arecord1" ttl = 300 records = ["10.1.1.1", "10.1.1.2"] tags = { "env" = "prod" } } "record2" = { name = "my_arecord2" ttl = 300 records = ["10.2.1.1", "10.2.1.2"] tags = { "env" = "dev" } } } } module "dns_a_record" { for_each = local.a_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_a_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl a_records = each.value.records tags = each.value.tags } ``` -------------------------------- ### Basic SRV Record Example Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_srv_record/_header.md This example demonstrates the basic usage of the module for adding SRV records to an existing private DNS zone using Terraform's for_each iteration. It defines multiple SRV records with their respective priorities, weights, ports, and targets. ```terraform locals { srv_records = { "srv_record1" = { name = "srv1" ttl = 300 records = { "srvrecordA" = { priority = 1 weight = 5 port = 8080 target = "targetA.testlab.io" } "srvrecordB" = { priority = 2 weight = 5 port = 8080 target = "targetB.testlab.io" } } tags = { "env" = "prod" } } "srv_record2" = { name = "srv2" ttl = 300 records = { "srvrecordC" = { priority = 3 weight = 5 port = 8080 target = "targetC.testlab.io" } "srvrecordD" = { priority = 4 weight = 5 port = 8080 target = "targetD.testlab.io" } } tags = { "env" = "dev" } } } } module "dns_srv_record" { for_each = local.srv_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_srv_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl records = each.value.records tags = each.value.tags } ``` -------------------------------- ### Terraform Plan Output Example Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/README.md This example illustrates a potential output during a 'terraform plan' after an initial deployment. It highlights changes to 'number_of_record_sets' detected outside of Terraform, which will be updated in the state upon 'apply' without altering infrastructure. ```text Note: Objects have changed outside of Terraform Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected this plan: ~ number_of_record_sets = 15 -> 17 You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure. ``` -------------------------------- ### Basic Virtual Network Link Example Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_virtual_network_link/_header.md This example demonstrates the basic usage of the module for creating virtual network links to an existing private DNS zone using Terraform's for_each iteration. It requires parent_id, name, and virtual_network_id as inputs. ```terraform locals { vnet_links = { "vnet_hub_primary" = { name = "primary-hub-mydomain-link" virtual_network_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnetNameEastUS2" registration_enabled = true resolution_policy = "NxDomainRedirect" tags = { "env" = "prod" } } "vnet_hub_dr" = { name = "dr-hub-mydomain-link" virtual_network_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnetNameCentralUS" registration_enabled = true resolution_policy = "NxDomainRedirect" tags = { "env" = "prod" } } } } module "private_dns_zone_vnet_link" { for_each = local.vnet_links source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_virtual_network_link" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name virtual_network_id = each.value.virtual_network_id registration_enabled = each.value.registration_enabled resolution_policy = each.value.resolution_policy tags = each.value.tags } ``` -------------------------------- ### Basic CNAME Record Usage Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_cname_record/README.md This example demonstrates the fundamental usage of the module for adding CNAME records to an existing private DNS zone. It utilizes the `for_each` meta-argument to create multiple records based on a local variable definition. ```terraform locals { cname_records = { "record1" = { name = "my_cname_record1" ttl = 300 record = "prod.testlab.io" tags = { "env" = "prod" } } "record2" = { name = "my_cname_record2" ttl = 300 record = "dev.testlab.io" tags = { "env" = "dev" } } } } module "dns_cname_record" { for_each = local.cname_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_cname_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl record = each.value.record tags = each.value.tags } ``` -------------------------------- ### Basic PTR Record Creation Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_ptr_record/_header.md This example demonstrates the most basic usage of the module for adding PTR records to an existing private DNS zone using Terraform's for_each iteration. It requires the parent_id and name variables, along with optional variables for the DNS record details. ```terraform locals { ptr_records = { "ptr_record1" = { name = "ptr1" ttl = 300 records = ["web1.testlab.io", "web2.testlab.io"] tags = { "env" = "prod" } } "ptr_record2" = { name = "ptr2" ttl = 300 records = ["web1.testlab.io", "web2.testlab.io"] tags = { "env" = "dev" } } } } module "dns_ptr_record" { for_each = local.ptr_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_ptr_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl records = each.value.records tags = each.value.tags } ``` -------------------------------- ### Basic MX Record Usage Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_mx_record/README.md This example demonstrates the fundamental usage of the private DNS MX record module, illustrating how to define and apply multiple MX records to an existing private DNS zone via Terraform's for_each meta-argument. ```terraform locals { mx_records = { "mx_record1" = { name = "primary" ttl = 300 records = { "record1" = { preference = 10 exchange = "mail1.testlab.io" } "record2" = { preference = 20 exchange = "mail2.testlab.io" } } tags = { "env" = "prod" } } "msx_record2" = { name = "backupmail" ttl = 300 records = { "record3" = { preference = 10 exchange = "backupmail1.testlab.io" } "record4" = { preference = 20 exchange = "backupmail2.testlab.io" } } tags = { "env" = "dev" } } } } module "dns_mx_record" { for_each = local.mx_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_mx_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl records = each.value.records tags = each.value.tags } ``` -------------------------------- ### Configure timeouts for private DNS zone Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/examples/timeouts/README.md This example configures custom timeouts for both DNS zone and virtual network link operations within the private DNS zone module. Adjust these values based on expected resource provisioning times. ```hcl module "private_dns_zone" { # replace source with the correct link to the private_dns_zone module # source = "Azure/avm-res-network-privatednszone/azurerm" source = "../../" domain_name = local.domain_name parent_id = local.parent_id a_records = local.a_records aaaa_records = local.aaaa_records cname_records = local.cname_records enable_telemetry = local.enable_telemetry mx_records = local.mx_records ptr_records = local.ptr_records soa_record = local.soa_record srv_records = local.srv_records tags = local.tags timeouts = { dns_zones = { create = "50m" delete = "50m" read = "10m" update = "50m" } vnet_links = { create = "50m" delete = "50m" read = "10m" update = "50m" } } txt_records = local.txt_records virtual_network_links = local.virtual_network_links } ``` -------------------------------- ### Basic MX Record Usage with for_each Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_mx_record/_header.md This example demonstrates the fundamental usage of the private DNS MX record module. It utilizes the `for_each` meta-argument to create multiple MX records based on a local variable definition. Ensure `parent_id` and `name` are provided, along with MX record details. ```terraform locals { mx_records = { "mx_record1" = { name = "primary" ttl = 300 records = { "record1" = { preference = 10 exchange = "mail1.testlab.io" } "record2" = { preference = 20 exchange = "mail2.testlab.io" } } tags = { "env" = "prod" } } "msx_record2" = { name = "backupmail" ttl = 300 records = { "record3" = { preference = 10 exchange = "backupmail1.testlab.io" } "record4" = { preference = 20 exchange = "backupmail2.testlab.io" } } tags = { "env" = "dev" } } } } module "dns_mx_record" { for_each = local.mx_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_mx_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl records = each.value.records tags = each.value.tags } ``` -------------------------------- ### Basic AAAA Record Usage Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_aaaa_record/_header.md This example demonstrates the basic usage of the module for adding AAAA records to an existing private DNS zone using for_each iteration. Ensure 'parent_id' and 'name' are provided, along with optional record details. ```terraform locals { aaaa_records = { "record1" = { name = "my_aaaarecord1" ttl = 600 records = ["fd5d:70bc:930e:d008:0000:0000:0000:7334", "fd5d:70bc:930e:d008::7335"] tags = { "env" = "prod" } } "record2" = { name = "my_aaaarecord2" ttl = 600 records = ["fd5d:70bc:930e:d008:0000:0000:0000:7334", "fd5d:70bc:930e:d008::7335"] tags = { "env" = "dev" } } } } module "dns_aaaa_record" { for_each = local.aaaa_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_aaaa_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl aaaa_records = each.value.records tags = each.value.tags } ``` -------------------------------- ### Add Basic CNAME Records with for_each Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_cname_record/_header.md This example demonstrates the basic usage of the module to add multiple CNAME records to an existing private DNS zone using Terraform's for_each meta-argument. Ensure the parent_id and name variables are provided. ```terraform locals { cname_records = { "record1" = { name = "my_cname_record1" ttl = 300 record = "prod.testlab.io" tags = { "env" = "prod" } } "record2" = { name = "my_cname_record2" ttl = 300 record = "dev.testlab.io" tags = { "env" = "dev" } } } } module "dns_cname_record" { for_each = local.cname_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_cname_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl record = each.value.record tags = each.value.tags } ``` -------------------------------- ### Terraform Plan Output Example Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/_header.md This output may appear after an initial deployment when running 'terraform plan' again. It indicates changes to Terraform output values like 'number_of_record_sets' made outside of Terraform. Running 'apply' will update the state but not change infrastructure. ```terraform Note: Objects have changed outside of Terraform Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected this plan: ~ number_of_record_sets = 15 -> 17 You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure. ``` -------------------------------- ### Basic A Record Creation with for_each Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_a_record/README.md Demonstrates how to create multiple A records in a private DNS zone using the `for_each` meta-argument. Ensure the `parent_id` points to an existing private DNS zone. ```terraform locals { a_records = { "record1" = { name = "my_arecord1" ttl = 300 records = ["10.1.1.1", "10.1.1.2"] tags = { "env" = "prod" } } "record2" = { name = "my_arecord2" ttl = 300 records = ["10.2.1.1", "10.2.1.2"] tags = { "env" = "dev" } } } } module "dns_a_record" { for_each = local.a_records source = "Azure/terraform-azurerm-avm-res-network-privatednszone/azurerm//modules/private_dns_a_record" parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/privateDnsZones/mydomain.com" name = each.value.name ttl = each.value.ttl a_records = each.value.records tags = each.value.tags } ``` -------------------------------- ### Deploy module with custom timeouts Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/examples/timeouts/README.md This snippet shows how to configure custom timeouts for the virtual network module. Use this when default timeouts are insufficient for your environment's deployment speed. ```hcl module "vnet" { source = "Azure/avm-res-network-virtualnetwork/azurerm" version = "0.9.1" address_space = ["10.0.0.0/16"] location = azurerm_resource_group.avmrg.location resource_group_name = azurerm_resource_group.avmrg.name enable_telemetry = local.enable_telemetry name = module.naming.virtual_network.name retry = { error_message_regex = ["CannotDeleteResource"] attempts = 3 delay = "10s" } subnets = { subnet1 = { name = "subnet1" address_prefix = "10.0.1.0/24" } } timeouts = { create = "5m" update = "5m" delete = "5m" } } ``` -------------------------------- ### Basic Module Usage Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/_header.md Use this snippet to instantiate the Private DNS Zone module. Provide values for mandatory variables like domain name and resource group name. ```terraform module "azure_privatednszone" { source = "./path_to_this_module" // ... mandatory variables ... domain_name = "your.domain.com" resource_group_name = "existing_resourcegroup_name" // ... other optional variables, see example ... } ``` -------------------------------- ### Deploy Private DNS Zone with Resource Lock Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/examples/lock/README.md This snippet deploys a private DNS zone with a resource lock. It includes configurations for retry attempts, delays, and timeouts for DNS zone and virtual network link operations. Ensure the `azurerm` provider is configured and the necessary modules are available. ```hcl data "azurerm_client_config" "current" {} module "naming" { source = "Azure/naming/azurerm" version = "0.4.2" } # create the resource group resource "azurerm_resource_group" "avmrg" { location = "EastUS" name = module.naming.resource_group.name_unique } # reference the module and pass in variables as needed module "private_dns_zone" { # replace source with the correct link to the private_dns_zone module # source = "Azure/avm-res-network-privatednszone/azurerm" source = "../../" domain_name = local.domain_name parent_id = local.parent_id enable_telemetry = local.enable_telemetry lock = local.lock retry = { error_message_regex = ["CannotDeleteResource"] attempts = 3 delay = "10s" } tags = local.tags timeouts = { dns_zones = { create = "50m" delete = "50m" read = "10m" update = "50m" } vnet_links = { create = "50m" delete = "50m" read = "10m" update = "50m" } } } ``` -------------------------------- ### Terraform Configuration for Private DNS Zone Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/examples/resolutionpolicy/README.md This configuration sets up a private DNS zone and links it to a virtual network. It requires the Azure provider and specific modules for naming, resource group, virtual network, and the private DNS zone itself. Ensure the 'private_dns_zone' module source is correctly pointed to your module. ```hcl data "azurerm_client_config" "current" {} module "naming" { source = "Azure/naming/azurerm" version = "0.4.2" } # create the resource group resource "azurerm_resource_group" "avmrg" { location = "EastUS" name = module.naming.resource_group.name_unique } # create first sample virtual network module "vnet" { source = "Azure/avm-res-network-virtualnetwork/azurerm" version = "0.9.1" address_space = ["10.0.0.0/16"] location = azurerm_resource_group.avmrg.location resource_group_name = azurerm_resource_group.avmrg.name enable_telemetry = local.enable_telemetry name = module.naming.virtual_network.name retry = { error_message_regex = ["CannotDeleteResource"] attempts = 3 delay = "10s" } subnets = { subnet1 = { name = "subnet1" address_prefix = "10.0.1.0/24" } } timeouts = { create = "5m" update = "5m" delete = "5m" } } # reference the module and pass in variables as needed module "private_dns_zone" { # replace source with the correct link to the private_dns_zone module # source = "Azure/avm-res-network-privatednszone/azurerm" source = "../../" domain_name = local.domain_name parent_id = local.parent_id enable_telemetry = local.enable_telemetry tags = local.tags virtual_network_links = local.virtual_network_links } module "avm_storageaccount" { source = "Azure/avm-res-storage-storageaccount/azurerm" version = "0.5.0" location = azurerm_resource_group.avmrg.location name = module.naming.storage_account.name_unique resource_group_name = azurerm_resource_group.avmrg.name private_endpoints = { private_endpoint_1 = { name = module.naming.private_endpoint.name_unique subnet_resource_id = module.vnet.subnets["subnet1"].resource_id subresource_name = "blob" private_dns_zone_resource_ids = [module.private_dns_zone.resource_id] } } role_assignments = { role_assignment_1 = { role_definition_id_or_name = "Storage Blob Data Owner" principal_id = data.azurerm_client_config.current.object_id principal_type = "ServicePrincipal" skip_service_principal_aad_check = false } } tags = local.tags } ``` -------------------------------- ### Custom Timeouts for Virtual Network Link Operations Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_virtual_network_link/README.md Defines custom timeouts for create, update, read, and delete operations. Defaults to 10 minutes for each. ```hcl object({ create = optional(string, "10m") update = optional(string, "10m") read = optional(string, "10m") delete = optional(string, "10m") }) ``` -------------------------------- ### Default Timeouts Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/modules/private_dns_virtual_network_link/README.md Specifies the default timeout values for virtual network link operations when custom timeouts are not provided. ```json { "create": "10m", "delete": "10m", "read": "10m", "update": "10m" } ``` -------------------------------- ### Deploy Azure Private DNS Zone with Terraform Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/examples/default/README.md This configuration deploys a Private DNS Zone in Azure using Terraform. It sets up a resource group, two virtual networks, and then configures the Private DNS Zone with various record types and virtual network links. Ensure the module source path is correct for your project structure. ```hcl data "azurerm_client_config" "current" {} module "naming" { source = "Azure/naming/azurerm" version = "0.4.2" } # create the resource group resource "azurerm_resource_group" "avmrg" { location = "EastUS" name = module.naming.resource_group.name_unique } # create first sample virtual network module "vnet1" { source = "Azure/avm-res-network-virtualnetwork/azurerm" version = "0.9.1" address_space = ["10.0.0.0/16"] location = azurerm_resource_group.avmrg.location resource_group_name = azurerm_resource_group.avmrg.name enable_telemetry = local.enable_telemetry name = "vnet1" retry = { error_message_regex = ["CannotDeleteResource"] attempts = 3 delay = "10s" } subnets = { subnet1 = { name = "subnet1" address_prefix = "10.0.1.0/24" } } timeouts = { create = "5m" update = "5m" delete = "5m" } } # create second sample virtual network module "vnet2" { source = "Azure/avm-res-network-virtualnetwork/azurerm" version = "0.9.1" address_space = ["10.1.0.0/16"] location = azurerm_resource_group.avmrg.location resource_group_name = azurerm_resource_group.avmrg.name enable_telemetry = local.enable_telemetry name = "vnet2" retry = { error_message_regex = ["CannotDeleteResource"] attempts = 3 delay = "10s" } subnets = { subnet2 = { name = "subnet2" address_prefix = "10.1.1.0/24" } } timeouts = { create = "5m" update = "5m" delete = "5m" } } # reference the module and pass in variables as needed module "private_dns_zone" { # replace source with the correct link to the private_dns_zone module # source = "Azure/avm-res-network-privatednszone/azurerm" source = "../../" domain_name = local.domain_name parent_id = local.parent_id a_records = local.a_records aaaa_records = local.aaaa_records cname_records = local.cname_records enable_telemetry = local.enable_telemetry mx_records = local.mx_records ptr_records = local.ptr_records retry = { error_message_regex = ["CannotDeleteResource"] attempts = 3 delay = "10s" } role_assignments = local.role_assignments soa_record = local.soa_record srv_records = local.srv_records tags = local.tags timeouts = { dns_zones = { create = "50m" delete = "50m" read = "10m" update = "50m" } vnet_links = { create = "50m" delete = "50m" read = "10m" update = "50m" } } txt_records = local.txt_records virtual_network_links = local.virtual_network_links } ``` -------------------------------- ### A Record Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/README.md Defines A records for the private DNS zone. Each record requires a name, TTL, and can optionally specify a list of IP addresses. ```hcl map(object({ name = string ttl = number records = optional(list(string)) ip_addresses = optional(set(string), null) })) ``` -------------------------------- ### CNAME Record Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/README.md Defines CNAME records for the private DNS zone. Each record requires a name, TTL, and can optionally specify a target record or CNAME. ```hcl map(object({ name = string ttl = number record = optional(string, null) cname = optional(string, null) })) ``` -------------------------------- ### Provision Private DNS Zone and Add Records Source: https://github.com/azure/terraform-azurerm-avm-res-network-privatednszone/blob/main/examples/dns_records/README.md This Terraform configuration provisions an Azure Resource Group and a Private DNS Zone, then adds various DNS record types using dedicated modules. Ensure the 'private_dns_zone' module source is correctly set to your module path. ```hcl data "azurerm_client_config" "current" {} module "naming" { source = "Azure/naming/azurerm" version = "0.4.2" } # create the resource group resource "azurerm_resource_group" "avmrg" { location = "EastUS" name = module.naming.resource_group.name_unique } module "private_dns_zone" { # replace source with the correct link to the private_dns_zone module # source = "Azure/avm-res-network-privatednszone/azurerm" source = "../../" domain_name = local.domain_name parent_id = local.parent_id } module "a_record" { source = "../../modules/private_dns_a_record" for_each = local.a_records ip_addresses = each.value.ip_addresses name = each.value.name parent_id = module.private_dns_zone.resource_id ttl = each.value.ttl } module "aaaa_record" { source = "../../modules/private_dns_aaaa_record" for_each = local.aaaa_records ip_addresses = each.value.ip_addresses name = each.value.name parent_id = module.private_dns_zone.resource_id ttl = each.value.ttl } module "cname_record" { source = "../../modules/private_dns_cname_record" for_each = local.cname_records cname = each.value.cname name = each.value.name parent_id = module.private_dns_zone.resource_id ttl = each.value.ttl } module "mx_record" { source = "../../modules/private_dns_mx_record" for_each = local.mx_records name = each.value.name parent_id = module.private_dns_zone.resource_id records = values(each.value.records) ttl = each.value.ttl } module "ptr_record" { source = "../../modules/private_dns_ptr_record" for_each = local.ptr_records domain_names = each.value.domain_names name = each.value.name parent_id = module.private_dns_zone.resource_id ttl = each.value.ttl } module "srv_record" { source = "../../modules/private_dns_srv_record" for_each = local.srv_records name = each.value.name parent_id = module.private_dns_zone.resource_id records = values(each.value.records) ttl = each.value.ttl } module "txt_record" { source = "../../modules/private_dns_txt_record" for_each = local.txt_records name = each.value.name parent_id = module.private_dns_zone.resource_id records = values(each.value.records) ttl = each.value.ttl } ```