Azure Network Public IP

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

azurerm_public_ip (Terraform)

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

Example Usage from GitHub

pip_nic.tf#L1
resource "azurerm_public_ip" "manager_pip" {
  name                         = "cdh-pip"
  location                     = var.location
  resource_group_name          = azurerm_resource_group.terraform_rg.name
  allocation_method            = "Static"

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 Public IP Address.

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

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

Example Usage from GitHub

storageAccountVirtualNetworkPublicIP.json#L90
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[parameters('primaryDCIPAddressNameWithSuffix')]",
      "location": "[parameters('location')]",
      "properties": {
        "publicIPAllocationMethod": "dynamic"
      }
PublicIPAddressListAll.json#L7
      "type": "Microsoft.Network/publicIPAddresses",
      "location": "northeurope",
      "tags": {
        "testkey": "testvalue"
      },
      "properties": {
creatingPublicIP-RDP.json#L18
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[parameters('pdcRdpIPAddressName')]",
      "location": "[parameters('location')]",
      "properties": {
        "publicIPAllocationMethod": "dynamic"
      }
creatingPublicIP-RDP.json#L18
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[parameters('pdcRdpIPAddressName')]",
      "location": "[parameters('location')]",
      "properties": {
        "publicIPAllocationMethod": "dynamic"
      }
creatingPublicIP-RDP.json#L18
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[parameters('pdcRdpIPAddressName')]",
      "location": "[parameters('location')]",
      "properties": {
        "publicIPAllocationMethod": "dynamic"
      }
creatingPublicIP-RDP.json#L21
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[parameters('pdcRdpIPAddressName')]",
      "location": "[parameters('location')]",
      "properties": {
        "publicIPAllocationMethod": "dynamic"
      }
PublicIPAddressList.json#L7
      "type": "Microsoft.Network/publicIPAddresses",
      "location": "northeurope",
      "tags": {
        "testkey": "testvalue"
      },
      "properties": {
Microsoft.Network.PublicIp.tests.json#L8
        "type":"Microsoft.Network/publicIPAddresses",
        "name":"[variables('publicIPAddressName')]",
        "location":"[resourceGroup().location]",
        "properties":{
          "publicIPAllocationMethod":"[parameters('publicIPAddressType')]"
        }
creatingPublicIPs.json#L40
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[parameters('dcPublicIPAddressName')]",
      "location": "[parameters('location1')]",
      "properties": {
        "publicIPAllocationMethod": "[parameters('dcPublicIPAddressType')]"
      }
publicIP.json#L34
        "type": "Microsoft.Network/publicIPAddresses",
        "location": "[resourceGroup().location]",
        "apiVersion": "[parameters('publicIpApiVersion')]",
        "tags": {
          "displayName": "[variables('publicIpName1')]"
        },

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.

  • sku optional
      • name optional - string

        Name of a public IP address SKU.

      • tier optional - string

        Tier of a public IP address SKU.

  • properties required
      • publicIPAllocationMethod required - string

        The public IP address allocation method.

      • publicIPAddressVersion optional - string

        The public IP address version.

      • dnsSettings optional
          • domainNameLabel required - string

            The domain name label. The concatenation of the domain name label and the regionalized DNS zone make up the fully qualified domain name associated with the public IP address. If a domain name label is specified, an A DNS record is created for the public IP in the Microsoft Azure DNS system.

          • fqdn optional - string

            The Fully Qualified Domain Name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.

          • reverseFqdn optional - string

            The reverse FQDN. A user-visible, fully qualified domain name that resolves to this public IP address. If the reverseFqdn is specified, then a PTR DNS record is created pointing from the IP address in the in-addr.arpa domain to the reverse FQDN.

      • ddosSettings optional
          • ddosCustomPolicy optional
              • id required - string

                Resource ID.

          • protectionCoverage optional - string

            The DDoS protection policy customizability of the public IP. Only standard coverage will have the ability to be customized.

          • protectedIP optional - boolean

            Enables DDoS protection on the public IP.

      • ipTags optional array
          • ipTagType optional - string

            The IP tag type. Example: FirstPartyUsage.

          • tag optional - string

            The value of the IP tag associated with the public IP. Example: SQL.

      • ipAddress optional - string

        The IP address associated with the public IP address resource.

      • publicIPPrefix optional
          • id required - string

            Resource ID.

      • idleTimeoutInMinutes optional - integer

        The idle timeout of the public IP address.

  • zones optional - array

    A list of availability zones denoting the IP allocated for the resource needs to come from.

Frequently asked questions

What is Azure Network Public IP?

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

For Terraform, the jirojo2/cdh-cloud source code example is useful. See the Terraform Example section for further details.

For Azure Resource Manager, the millusdk/Arm-high-availability, apache/jclouds and carrollh/siosDataKeeper-demo source code examples are useful. See the Azure Resource Manager Example section for further details.