Azure Network Public IP Prefix Association

This page shows how to write Terraform and Azure Resource Manager for Network Public IP Prefix Association and write them securely.

azurerm_nat_gateway_public_ip_prefix_association (Terraform)

The Public IP Prefix Association in Network can be configured in Terraform with the resource name azurerm_nat_gateway_public_ip_prefix_association. The following sections describe 1 example of how to use the resource and its parameters.

Example Usage from GitHub

nat_gateway.tf#L29
resource "azurerm_nat_gateway_public_ip_prefix_association" "azurerm_nat_gateway_public_ip_prefix_association" {
  nat_gateway_id      = azurerm_nat_gateway.azurerm_nat_gateway.id
  public_ip_prefix_id = azurerm_public_ip_prefix.azurerm_public_ip_prefix.id
}

resource "azurerm_subnet_nat_gateway_association" "example" {

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

The following arguments are supported:

  • nat_gateway_id - (Required) The ID of the Nat Gateway. Changing this forces a new resource to be created.

  • public_ip_prefix_id - (Required) The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.

The following attributes are exported:

  • id - The (Terraform specific) ID of the Association between the Nat Gateway and the Public IP Prefix.

Explanation in Terraform Registry

Manages the association between a Nat Gateway and a Public IP Prefix.

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/natGateways (Azure Resource Manager)

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

Example Usage from GitHub

NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",
NatGatewayCreateOrUpdate.json#L54
        "type": "Microsoft.Network/natGateways"
      }
    },
    "201": {
      "body": {
        "name": "test-natGateway",

Parameters

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

    Resource location.

  • tags optional - string

    Resource tags.

  • sku optional
      • name optional - string

        Name of Nat Gateway SKU.

  • properties required
      • idleTimeoutInMinutes optional - integer

        The idle timeout of the nat gateway.

      • publicIpAddresses optional array
          • id required - string

            Resource ID.

      • publicIpPrefixes optional array
          • id required - string

            Resource ID.

  • zones optional - array

    A list of availability zones denoting the zone in which Nat Gateway should be deployed.

Frequently asked questions

What is Azure Network Public IP Prefix Association?

Azure Network Public IP Prefix Association 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 Public IP Prefix Association?

For Terraform, the Gompei/azure-terraform source code example is useful. See the Terraform Example section for further details.

For Azure Resource Manager, the jashsing-mic/azure-rest-api-specs, jashsing-mic/azure-rest-api-specs and jashsing-mic/azure-rest-api-specs source code examples are useful. See the Azure Resource Manager Example section for further details.