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_serversoptional computed - list of string -
dns_serversoptional computed - list of string -
enable_accelerated_networkingoptional - bool -
enable_ip_forwardingoptional - bool -
idoptional computed - string -
internal_dns_name_labeloptional computed - string -
internal_domain_name_suffixoptional computed - string -
locationrequired - string -
mac_addressoptional computed - string -
namerequired - string -
private_ip_addressoptional computed - string -
private_ip_addressesoptional computed - list of string -
resource_group_namerequired - string -
tagsoptional - map from string to string -
virtual_machine_idoptional computed - string -
ip_configurationlist block-
namerequired - string -
primaryoptional computed - bool -
private_ip_addressoptional computed - string -
private_ip_address_allocationrequired - string -
private_ip_address_versionoptional - string -
public_ip_address_idoptional - string -
subnet_idoptional - string
-
-
timeoutssingle 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
namerequired - stringtyperequired - stringapiVersionrequired - stringlocationrequired - stringResource location.
tagsoptional - stringResource tags.
extendedLocationoptionalnamerequired - stringThe name of the extended location.
typerequired - stringThe type of the extended location.
propertiesrequirednetworkSecurityGroupoptionalidrequired - stringResource ID.
ipConfigurationsrequired arraypropertiesoptionalvirtualNetworkTapsoptional arrayidrequired - stringResource ID.
applicationGatewayBackendAddressPoolsoptional arrayidrequired - stringResource ID.
loadBalancerBackendAddressPoolsoptional arrayidrequired - stringResource ID.
loadBalancerInboundNatRulesoptional arrayidrequired - stringResource ID.
privateIPAddressoptional - stringPrivate IP address of the IP configuration.
privateIPAllocationMethodoptional - stringThe private IP address allocation method.
privateIPAddressVersionoptional - stringWhether the specific IP configuration is IPv4 or IPv6. Default is IPv4.
subnetoptionalidrequired - stringResource ID.
primaryoptional - booleanWhether this is a primary customer address on the network interface.
publicIPAddressoptionalidrequired - stringResource ID.
applicationSecurityGroupsoptional arrayidrequired - stringResource ID.
namerequired - stringThe name of the resource that is unique within a resource group. This name can be used to access the resource.
dnsSettingsoptionaldnsServersoptional - 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.
internalDnsNameLabeloptional - stringRelative DNS name for this NIC used for internal communications between VMs in the same virtual network.
enableAcceleratedNetworkingoptional - booleanIf the network interface is accelerated networking enabled.
enableIPForwardingoptional - 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.