Skip to content

azurermPublicIp

Manages a Public IP Address.

\~> Note If this resource is to be associated with a resource that requires disassociation before destruction (such as azurermNetworkInterface) it is recommended to set the lifecycle argument createBeforeDestroy =True. Otherwise, it can fail to disassociate on destruction.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermPublicIpExample = new azurerm.publicIp.PublicIp(
  this,
  "example_1",
  {
    allocation_method: "Static",
    location: azurermResourceGroupExample.location,
    name: "acceptanceTestPublicIp1",
    resource_group_name: azurermResourceGroupExample.name,
    tags: {
      environment: "Production",
    },
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermPublicIpExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Public IP. Changing this forces a new Public IP to be created.

  • resourceGroupName - (Required) The name of the Resource Group where this Public IP should exist. Changing this forces a new Public IP to be created.

  • location - (Required) Specifies the supported Azure location where the Public IP should exist. Changing this forces a new resource to be created.

  • allocationMethod - (Required) Defines the allocation method for this IP address. Possible values are static or dynamic.

\~> Note dynamic Public IP Addresses aren't allocated until they're assigned to a resource (such as a Virtual Machine or a Load Balancer) by design within Azure. See ipAddress argument.


  • zones - (Optional) A collection containing the availability zone to allocate the Public IP in. Changing this forces a new resource to be created.

-> Note: Availability Zones are only supported with a Standard SKU and in select regions at this time. Standard SKU Public IP Addresses that do not specify a zone are not zone-redundant by default.

  • ddosProtectionMode - (Optional) The DDoS protection mode of the public IP. Possible values are disabled, enabled, and virtualNetworkInherited. Defaults to virtualNetworkInherited.

  • ddosProtectionPlanId - (Optional) The ID of DDoS protection plan associated with the public IP.

-> Note: ddosProtectionPlanId can only be set when ddosProtectionMode is enabled.

  • domainNameLabel - (Optional) Label for the Domain Name. Will be used to make up the FQDN. If a domain name label is specified, an A DNS record is created for the public IP in the Microsoft Azure DNS system.

  • edgeZone - (Optional) Specifies the Edge Zone within the Azure Region where this Public IP should exist. Changing this forces a new Public IP to be created.

  • idleTimeoutInMinutes - (Optional) Specifies the timeout for the TCP idle connection. The value can be set between 4 and 30 minutes.

  • ipTags - (Optional) A mapping of IP tags to assign to the public IP. Changing this forces a new resource to be created.

-> Note IP Tag routingPreference requires multiple zones and standard SKU to be set.

  • ipVersion - (Optional) The IP Version to use, IPv6 or IPv4. Changing this forces a new resource to be created.

-> Note Only static IP address allocation is supported for IPv6.

  • publicIpPrefixId - (Optional) If specified then public IP address allocated will be provided from the public IP prefix resource. Changing this forces a new resource to be created.

  • reverseFqdn - (Optional) A 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.

  • sku - (Optional) The SKU of the Public IP. Accepted values are basic and standard. Defaults to basic. Changing this forces a new resource to be created.

-> Note Public IP Standard SKUs require allocationMethod to be set to static.

  • skuTier - (Optional) The SKU Tier that should be used for the Public IP. Possible values are regional and global. Defaults to regional. Changing this forces a new resource to be created.

-> Note When skuTier is set to global, sku must be set to standard.

  • tags - (Optional) A mapping of tags to assign to the resource.

Attributes Reference

The following attributes are exported:

  • id - The ID of this Public IP.

  • ipAddress - The IP address value that was allocated.

\~> Note dynamic Public IP Addresses aren't allocated until they're attached to a device (e.g. a Virtual Machine/Load Balancer). Instead you can obtain the IP Address once the Public IP has been assigned via the azurermPublicIp Data Source.

  • fqdn - Fully qualified domain name of the A DNS record associated with the public IP. domainNameLabel must be specified to get the fqdn. This is the concatenation of the domainNameLabel and the regionalized DNS zone

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Public IP.
  • update - (Defaults to 30 minutes) Used when updating the Public IP.
  • read - (Defaults to 5 minutes) Used when retrieving the Public IP.
  • delete - (Defaults to 30 minutes) Used when deleting the Public IP.

Import

Public IPs can be imported using the resourceId, e.g.

terraform import azurerm_public_ip.myPublicIp /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPAddresses/myPublicIpAddress1