Azure Network Interface

This page shows how to write Terraform and Azure Resource Manager for Network Interface and write them securely.

azurerm_network_interface (Terraform)

The Interface in Network can be configured in Terraform with the resource name azurerm_network_interface. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

nic.tf#L1
resource "azurerm_network_interface" "nic1" {
  name                = "nic1"
  location            = var.location
  resource_group_name = var.resource_group_name
  ip_configuration {
    name                          = "testconfiguration1"
main.tf#L80
resource "azurerm_network_interface" "nic_helselog_web" {
  name                = "nic-helselog-web"
  location            = azurerm_resource_group.rg_helselog.location
  resource_group_name = azurerm_resource_group.rg_helselog.name

  ip_configuration {
network_cards.tf#L4
resource "azurerm_network_interface" "NIC_HaProxy" {
    name                        = "NIC_HaProxy"
    location                    = var.azure_location_Paris
    resource_group_name         = azurerm_resource_group.Ressource_Paris_HAProxy.name

    ip_configuration {
nic.tf#L1
resource "azurerm_network_interface" "nic1" {
  name                = "nic1"
  location            = var.location
  resource_group_name = var.resource_group_name
  ip_configuration {
    name                          = "testconfiguration1"
network.tf#L41
resource "azurerm_network_interface" "nic1" {
  name                      = "myNIC1"
  location                  = "westus2"
  resource_group_name       = azurerm_resource_group.rg.name

  ip_configuration {

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

Manages a Network Interface.

Tips: Best Practices for The Other Azure Network Resources

In addition to the azurerm_network_security_group, Azure Network has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_network_security_group

Ensure to disable RDP port from the Internet

It is better to disable the RDP port from the Internet. RDP access should not be accepted from the Internet (*, 0.0.0.0, /0, internet, any), and consider using the Azure Bastion Service.

risk-label

azurerm_network_security_rule

Ensure to set a more restrictive CIDR range for ingress from the internet

It is better to set a more restrictive CIDR range not to use very broad subnets. If possible, segments should be divided into smaller subnets.

risk-label

azurerm_network_watcher_flow_log

Ensure to enable Retention policy for flow logs and set it to enough duration

It is better to enable a retention policy for flow logs. Flow logs show us all network activity in the cloud environment and support us when we face critical incidents.

Review your Azure Network settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Network/networkInterfaces (Azure Resource Manager)

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

Example Usage from GitHub

creatingNICS.json#L66
      "type": "Microsoft.Network/networkInterfaces",
      "location": "[parameters('location')]",
      "apiVersion": "2015-06-15",
      "properties": {
        "ipConfigurations": [
          {
Microsoft.Network.NetworkInterface.tests.json#L8
        "type":"Microsoft.Network/networkInterfaces",
        "name":"[variables('nicName')]",
        "location":"[resourceGroup().location]",
        "properties":{
          "ipConfigurations":[
            {
NetworkInterfaceTest.test_find_by_name.json#L73
                                "type": "Microsoft.Network/networkInterfaces"
                            },
                            {
                                "name": "k8s-agent-C02B7042-nic-0",
                                "id": "/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/resourceGroups/test_containerservice/providers/Microsoft.Network/networkInterfaces/k8s-agent-C02B7042-nic-0",
                                "etag": "W/\"e0af135a-65df-45f7-9962-e2f1a7d9b719\"",
creatingNICS.json#L66
    "type": "Microsoft.Network/networkInterfaces",
    "location": "[parameters('location')]",
    "apiVersion": "2015-06-15",
    "properties": {
      "ipConfigurations": [
        {
creatingNICS.json#L66
      "type": "Microsoft.Network/networkInterfaces",
      "location": "[parameters('location')]",
      "apiVersion": "2015-06-15",
      "properties": {
        "ipConfigurations": [
          {
creatingNICS.json#L66
      "type": "Microsoft.Network/networkInterfaces",
      "location": "[parameters('location')]",
      "apiVersion": "2015-06-15",
      "properties": {
        "ipConfigurations": [
          {
creatingNICS.json#L66
      "type": "Microsoft.Network/networkInterfaces",
      "location": "[parameters('location')]",
      "apiVersion": "2015-06-15",
      "properties": {
        "ipConfigurations": [
          {
creatingNICS.json#L66
      "type": "Microsoft.Network/networkInterfaces",
      "location": "[parameters('location')]",
      "apiVersion": "2015-06-15",
      "properties": {
        "ipConfigurations": [
          {
creatingNICS.json#L66
      "type": "Microsoft.Network/networkInterfaces",
      "location": "[parameters('location')]",
      "apiVersion": "2015-06-15",
      "properties": {
        "ipConfigurations": [
          {
creatingNICS.json#L66
      "type": "Microsoft.Network/networkInterfaces",
      "location": "[parameters('location')]",
      "apiVersion": "2015-06-15",
      "properties": {
        "ipConfigurations": [
          {

Parameters

  • name required - string
  • type required - string
  • apiVersion required - string
  • location required - string

    Resource location.

  • tags optional - string

    Resource tags.

  • extendedLocation optional
      • name required - string

        The name of the extended location.

      • type required - string

        The type of the extended location.

  • properties required
      • networkSecurityGroup optional
          • id required - string

            Resource ID.

      • ipConfigurations required array
          • properties optional
              • virtualNetworkTaps optional array
                  • id required - string

                    Resource ID.

              • applicationGatewayBackendAddressPools optional array
                  • id required - string

                    Resource ID.

              • loadBalancerBackendAddressPools optional array
                  • id required - string

                    Resource ID.

              • loadBalancerInboundNatRules optional array
                  • id required - string

                    Resource ID.

              • privateIPAddress optional - string

                Private IP address of the IP configuration.

              • privateIPAllocationMethod optional - string

                The private IP address allocation method.

              • privateIPAddressVersion optional - string

                Whether the specific IP configuration is IPv4 or IPv6. Default is IPv4.

              • subnet optional
                  • id required - string

                    Resource ID.

              • primary optional - boolean

                Whether this is a primary customer address on the network interface.

              • publicIPAddress optional
                  • id required - string

                    Resource ID.

              • applicationSecurityGroups optional array
                  • id required - string

                    Resource ID.

          • name required - string

            The name of the resource that is unique within a resource group. This name can be used to access the resource.

      • dnsSettings optional
          • dnsServers optional - array

            List of DNS servers IP addresses. Use 'AzureProvidedDNS' to switch to azure provided DNS resolution. 'AzureProvidedDNS' value cannot be combined with other IPs, it must be the only value in dnsServers collection.

          • internalDnsNameLabel optional - string

            Relative DNS name for this NIC used for internal communications between VMs in the same virtual network.

      • enableAcceleratedNetworking optional - boolean

        If the network interface is accelerated networking enabled.

      • enableIPForwarding optional - boolean

        Indicates whether IP forwarding is enabled on this network interface.

Frequently asked questions

What is Azure Network Interface?

Azure Network Interface is a resource for Network of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Network Interface?

For Terraform, the azizbekmol/Terraform14, tirrrred/SP-IaC-Demo and etienne-plagnieux/Logskills_Terraform_Azure source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the sewalshmsft/AzureTemplates, Azure/autorest.azureresourceschema and moothumk/clodun source code examples are useful. See the Azure Resource Manager Example section for further details.