Skip to content

azurermNetworkInterface

Manages a Network Interface.

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-network",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*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 azurermSubnetExample = new azurerm.subnet.Subnet(this, "example_2", {
  address_prefixes: ["10.0.2.0/24"],
  name: "internal",
  resource_group_name: azurermResourceGroupExample.name,
  virtual_network_name: azurermVirtualNetworkExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSubnetExample.overrideLogicalId("example");
const azurermNetworkInterfaceExample =
  new azurerm.networkInterface.NetworkInterface(this, "example_3", {
    ip_configuration: [
      {
        name: "internal",
        private_ip_address_allocation: "Dynamic",
        subnet_id: azurermSubnetExample.id,
      },
    ],
    location: azurermResourceGroupExample.location,
    name: "example-nic",
    resource_group_name: azurermResourceGroupExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermNetworkInterfaceExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • ipConfiguration - (Required) One or more ipConfiguration blocks as defined below.

  • location - (Required) The location where the Network Interface should exist. Changing this forces a new resource to be created.

  • name - (Required) The name of the Network Interface. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the Resource Group in which to create the Network Interface. Changing this forces a new resource to be created.


  • dnsServers - (Optional) A list of IP Addresses defining the DNS Servers which should be used for this Network Interface.

-> Note: Configuring DNS Servers on the Network Interface will override the DNS Servers defined on the Virtual Network.

  • edgeZone - (Optional) Specifies the Edge Zone within the Azure Region where this Network Interface should exist. Changing this forces a new Network Interface to be created.

  • enableIpForwarding - (Optional) Should IP Forwarding be enabled? Defaults to false.

  • enableAcceleratedNetworking - (Optional) Should Accelerated Networking be enabled? Defaults to false.

-> Note: Only certain Virtual Machine sizes are supported for Accelerated Networking - more information can be found in this document.

-> Note: To use Accelerated Networking in an Availability Set, the Availability Set must be deployed onto an Accelerated Networking enabled cluster.

  • internalDnsNameLabel - (Optional) The (relative) DNS Name used for internal communications between Virtual Machines in the same Virtual Network.

  • tags - (Optional) A mapping of tags to assign to the resource.


The ipConfiguration block supports the following:

  • name - (Required) A name used for this IP Configuration.

  • gatewayLoadBalancerFrontendIpConfigurationId - (Optional) The Frontend IP Configuration ID of a Gateway SKU Load Balancer.

  • subnetId - (Optional) The ID of the Subnet where this Network Interface should be located in.

-> Note: This is required when privateIpAddressVersion is set to iPv4.

  • privateIpAddressVersion - (Optional) The IP Version to use. Possible values are iPv4 or iPv6. Defaults to iPv4.

  • privateIpAddressAllocation - (Required) The allocation method used for the Private IP Address. Possible values are dynamic and static.

\~> Note: dynamic means "An IP is automatically assigned during creation of this Network Interface"; static means "User supplied IP address will be used"

  • publicIpAddressId - (Optional) Reference to a Public IP Address to associate with this NIC

  • primary - (Optional) Is this the Primary IP Configuration? Must be true for the first ipConfiguration when multiple are specified. Defaults to false.

When privateIpAddressAllocation is set to static the following fields can be configured:

  • privateIpAddress - (Optional) The Static IP Address which should be used.

When privateIpAddressVersion is set to iPv4 the following fields can be configured:

  • subnetId - (Optional) The ID of the Subnet where this Network Interface should be located in.

Attributes Reference

The following attributes are exported:

  • appliedDnsServers - If the Virtual Machine using this Network Interface is part of an Availability Set, then this list will have the union of all DNS servers from all Network Interfaces that are part of the Availability Set.

  • id - The ID of the Network Interface.

  • internalDomainNameSuffix - Even if internalDnsNameLabel is not specified, a DNS entry is created for the primary NIC of the VM. This DNS name can be constructed by concatenating the VM name with the value of internalDomainNameSuffix.

  • macAddress - The Media Access Control (MAC) Address of the Network Interface.

  • privateIpAddress - The first private IP address of the network interface.

\~> Note: If a dynamic allocation method is used Azure will allocate an IP Address on Network Interface creation.

  • privateIpAddresses - The private IP addresses of the network interface.

\~> Note: If a dynamic allocation method is used Azure will allocate an IP Address on Network Interface creation.

  • virtualMachineId - The ID of the Virtual Machine which this Network Interface is connected to.

Timeouts

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

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

Import

Network Interfaces can be imported using the resourceId, e.g.

terraform import azurerm_network_interface.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkInterfaces/nic1