Skip to content

azurermNatGatewayPublicIpAssociation

Manages the association between a NAT Gateway and a Public IP.

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 azurermNatGatewayExample = new azurerm.natGateway.NatGateway(
  this,
  "example_1",
  {
    location: azurermResourceGroupExample.location,
    name: "example-NatGateway",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "Standard",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermNatGatewayExample.overrideLogicalId("example");
const azurermPublicIpExample = new azurerm.publicIp.PublicIp(
  this,
  "example_2",
  {
    allocation_method: "Static",
    location: azurermResourceGroupExample.location,
    name: "example-PIP",
    resource_group_name: azurermResourceGroupExample.name,
    sku: "Standard",
  }
);
/*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");
const azurermNatGatewayPublicIpAssociationExample =
  new azurerm.natGatewayPublicIpAssociation.NatGatewayPublicIpAssociation(
    this,
    "example_3",
    {
      nat_gateway_id: azurermNatGatewayExample.id,
      public_ip_address_id: azurermPublicIpExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermNatGatewayPublicIpAssociationExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

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

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

Attributes Reference

The following attributes are exported:

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

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the association between the NAT Gateway and the Public IP.
  • read - (Defaults to 5 minutes) Used when retrieving the association between the NAT Gateway and the Public IP.
  • delete - (Defaults to 30 minutes) Used when deleting the association between the NAT Gateway and the Public IP.

Import

Associations between NAT Gateway and Public IP Addresses can be imported using the resourceId, e.g.

terraform import azurerm_nat_gateway_public_ip_association.example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways/gateway1|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPAddresses/myPublicIpAddress1"

-> Note: This is a Terraform Specific ID in the format {natGatewayId}|{publicIpAddressId}