Azure Private DNS Cname Record

This page shows how to write Terraform and Azure Resource Manager for Private DNS Cname Record and write them securely.

azurerm_private_dns_cname_record (Terraform)

The Cname Record in Private DNS can be configured in Terraform with the resource name azurerm_private_dns_cname_record. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

private_dns_cname_record_test.tf#L15
resource "azurerm_private_dns_cname_record" "over1B" {
  name                = "test"
  zone_name           = azurerm_private_dns_zone.example.name
  resource_group_name = azurerm_resource_group.example.name
  ttl                 = 300
  record              = "contoso.com"
private_dns_cname_record_test.tf#L15
resource "azurerm_private_dns_cname_record" "over1B" {
  name                = "test"
  zone_name           = azurerm_private_dns_zone.example.name
  resource_group_name = azurerm_resource_group.example.name
  ttl                 = 300
  record              = "contoso.com"
terraform.tf#L23
resource "azurerm_private_dns_cname_record" "othertestcname" {
    name                = "othertest"
    zone_name           = azurerm_private_dns_zone.testzone.name
    resource_group_name = data.azurerm_resource_group.example.name
    ttl                 = 300
    record              = "othertest.com"
main.tf#L7
resource "azurerm_private_dns_cname_record" "this" {
  name                = var.name
  record              = var.record
  resource_group_name = var.resource_group_name
  tags                = var.tags
  ttl                 = var.ttl
main.tf#L27
resource "azurerm_private_dns_cname_record" "cname" {
  name                = var.private_dns_cname_record
  zone_name           = azurerm_private_dns_zone.dns_zone.name
  resource_group_name = var.resource_group_name
  ttl                 = var.ttl
  record              = var.record
main.tf#L28
resource "azurerm_private_dns_cname_record" "this" {
  for_each            = var.private_dns_cname_record_params
  name                = each.value.name
  zone_name           = each.value.zone_name
  resource_group_name = each.value.resource_group_name
  ttl                 = each.value.ttl
main.tf#L31
resource "azurerm_private_dns_cname_record" "dns-cname-record" {
  count               = length(var.cname_records)
  name                = var.cname_records[count.index].name
  zone_name           = azurerm_private_dns_zone.dns-private.name
  resource_group_name = data.azurerm_resource_group.dns.name
  ttl                 = var.cname_records[count.index].ttl
cname_record.tf#L1
resource "azurerm_private_dns_cname_record" "this" {
  for_each = { for record in var.cname_records : record.name => record }

  name                = lower(each.value.name)
  zone_name           = local.zone
  resource_group_name = var.resource_group_name
main.tf#L7
resource "azurerm_private_dns_cname_record" "this" {
  name                = var.name
  record              = var.record
  resource_group_name = var.resource_group_name
  tags                = var.tags
  ttl                 = var.ttl
module.tf#L29
resource "azurerm_private_dns_cname_record" "cname_records" {
  for_each = try(var.records.cname_records, {})

  name                = each.value.name
  resource_group_name = var.resource_group_name
  zone_name           = azurerm_private_dns_zone.private_dns.name

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Enables you to manage DNS CNAME Records within Azure Private DNS.

Microsoft.Network/privateDnsZones/CNAME (Azure Resource Manager)

The privateDnsZones/CNAME in Microsoft.Network can be configured in Azure Resource Manager with the resource name Microsoft.Network/privateDnsZones/CNAME. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Frequently asked questions

What is Azure Private DNS Cname Record?

Azure Private DNS Cname Record is a resource for Private DNS of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Private DNS Cname Record?

For Terraform, the gilyas/infracost, infracost/infracost and cloudskiff/driftctl source code examples are useful. See the Terraform Example section for further details.