Skip to content

azurermVirtualNetworkDnsServers

Manages the DNS servers associated with a virtual network.

\~> NOTE on Virtual Networks and DNS Servers: Terraform currently provides both a standalone virtual network DNS Servers resource, and allows for DNS servers to be defined in-line within the Virtual Network resource. At this time you cannot use a Virtual Network with in-line DNS servers in conjunction with any Virtual Network DNS Servers resources. Doing so will cause a conflict of Virtual Network DNS Servers configurations and will overwrite virtual networks DNS servers.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
  this,
  "example_1",
  {
    address_space: ["10.0.0.0/16"],
    location: azurermResourceGroupExample.location,
    name: "example-vnet",
    resource_group_name: azurermResourceGroupExample.name,
    subnet: [
      {
        address_prefix: "10.0.1.0/24",
        name: "subnet1",
      },
    ],
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermVirtualNetworkExample.overrideLogicalId("example");
const azurermVirtualNetworkDnsServersExample =
  new azurerm.virtualNetworkDnsServers.VirtualNetworkDnsServers(
    this,
    "example_2",
    {
      dns_servers: ["10.7.7.2", "10.7.7.7", "10.7.7.1"],
      virtual_network_id: azurermVirtualNetworkExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermVirtualNetworkDnsServersExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • virtualNetworkId - (Required) The ID of the Virtual Network that should be linked to the DNS Zone. Changing this forces a new resource to be created.

  • dnsServers - (Optional) List of IP addresses of DNS servers

Attributes Reference

The following attributes are exported:

  • id - The virtual network DNS server ID.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Virtual Network.
  • update - (Defaults to 30 minutes) Used when updating the Virtual Network.
  • read - (Defaults to 5 minutes) Used when retrieving the Virtual Network.
  • delete - (Defaults to 30 minutes) Used when deleting the Virtual Network.

Import

Virtual Network DNS Servers can be imported using the resourceId, e.g.

terraform import azurerm_virtual_network_dns_servers.exampleNetwork /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/virtualNetworks/myvnet1/dnsServers/default