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
resource "azurerm_network_interface" "nic1" {
name = "nic1"
location = var.location
resource_group_name = var.resource_group_name
ip_configuration {
name = "testconfiguration1"
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 {
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 {
resource "azurerm_network_interface" "nic1" {
name = "nic1"
location = var.location
resource_group_name = var.resource_group_name
ip_configuration {
name = "testconfiguration1"
resource "azurerm_network_interface" "nic1" {
name = "myNIC1"
location = "westus2"
resource_group_name = azurerm_resource_group.rg.name
ip_configuration {
Parameters
-
applied_dns_servers
optional computed - list of string -
dns_servers
optional computed - list of string -
enable_accelerated_networking
optional - bool -
enable_ip_forwarding
optional - bool -
id
optional computed - string -
internal_dns_name_label
optional computed - string -
internal_domain_name_suffix
optional computed - string -
location
required - string -
mac_address
optional computed - string -
name
required - string -
private_ip_address
optional computed - string -
private_ip_addresses
optional computed - list of string -
resource_group_name
required - string -
tags
optional - map from string to string -
virtual_machine_id
optional computed - string -
ip_configuration
list block-
name
required - string -
primary
optional computed - bool -
private_ip_address
optional computed - string -
private_ip_address_allocation
required - string -
private_ip_address_version
optional - string -
public_ip_address_id
optional - string -
subnet_id
optional - string
-
-
timeouts
single block
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.
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.
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.
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.
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
"type": "Microsoft.Network/networkInterfaces",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"properties": {
"ipConfigurations": [
{
"type":"Microsoft.Network/networkInterfaces",
"name":"[variables('nicName')]",
"location":"[resourceGroup().location]",
"properties":{
"ipConfigurations":[
{
"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\"",
"type": "Microsoft.Network/networkInterfaces",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"properties": {
"ipConfigurations": [
{
"type": "Microsoft.Network/networkInterfaces",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"properties": {
"ipConfigurations": [
{
"type": "Microsoft.Network/networkInterfaces",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"properties": {
"ipConfigurations": [
{
"type": "Microsoft.Network/networkInterfaces",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"properties": {
"ipConfigurations": [
{
"type": "Microsoft.Network/networkInterfaces",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"properties": {
"ipConfigurations": [
{
"type": "Microsoft.Network/networkInterfaces",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"properties": {
"ipConfigurations": [
{
"type": "Microsoft.Network/networkInterfaces",
"location": "[parameters('location')]",
"apiVersion": "2015-06-15",
"properties": {
"ipConfigurations": [
{
Parameters
name
required - stringtype
required - stringapiVersion
required - stringlocation
required - stringResource location.
tags
optional - stringResource tags.
extendedLocation
optionalname
required - stringThe name of the extended location.
type
required - stringThe type of the extended location.
properties
requirednetworkSecurityGroup
optionalid
required - stringResource ID.
ipConfigurations
required arrayproperties
optionalvirtualNetworkTaps
optional arrayid
required - stringResource ID.
applicationGatewayBackendAddressPools
optional arrayid
required - stringResource ID.
loadBalancerBackendAddressPools
optional arrayid
required - stringResource ID.
loadBalancerInboundNatRules
optional arrayid
required - stringResource ID.
privateIPAddress
optional - stringPrivate IP address of the IP configuration.
privateIPAllocationMethod
optional - stringThe private IP address allocation method.
privateIPAddressVersion
optional - stringWhether the specific IP configuration is IPv4 or IPv6. Default is IPv4.
subnet
optionalid
required - stringResource ID.
primary
optional - booleanWhether this is a primary customer address on the network interface.
publicIPAddress
optionalid
required - stringResource ID.
applicationSecurityGroups
optional arrayid
required - stringResource ID.
name
required - stringThe name of the resource that is unique within a resource group. This name can be used to access the resource.
dnsSettings
optionaldnsServers
optional - arrayList 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 - stringRelative DNS name for this NIC used for internal communications between VMs in the same virtual network.
enableAcceleratedNetworking
optional - booleanIf the network interface is accelerated networking enabled.
enableIPForwarding
optional - booleanIndicates 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.