Skip to content

azurermLbNatPool

Manages a Load Balancer NAT pool.

-> NOTE: This resource cannot be used with with virtual machines, instead use the azurermLbNatRule resource.

\~> NOTE When using this resource, the Load Balancer needs to have a FrontEnd IP Configuration Attached

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: "LoadBalancerRG",
  }
);
const azurermPublicIpExample = new azurerm.publicIp.PublicIp(
  this,
  "example_1",
  {
    allocation_method: "Static",
    location: azurermResourceGroupExample.location,
    name: "PublicIPForLB",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*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 azurermLbExample = new azurerm.lb.Lb(this, "example_2", {
  frontend_ip_configuration: [
    {
      name: "PublicIPAddress",
      public_ip_address_id: azurermPublicIpExample.id,
    },
  ],
  location: azurermResourceGroupExample.location,
  name: "TestLoadBalancer",
  resource_group_name: azurermResourceGroupExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLbExample.overrideLogicalId("example");
const azurermLbNatPoolExample = new azurerm.lbNatPool.LbNatPool(
  this,
  "example_3",
  {
    backend_port: 8080,
    frontend_ip_configuration_name: "PublicIPAddress",
    frontend_port_end: 81,
    frontend_port_start: 80,
    loadbalancer_id: azurermLbExample.id,
    name: "SampleApplicationPool",
    protocol: "Tcp",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLbNatPoolExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the NAT pool. Changing this forces a new resource to be created.
  • resourceGroupName - (Required) The name of the resource group in which to create the resource. Changing this forces a new resource to be created.
  • loadbalancerId - (Required) The ID of the Load Balancer in which to create the NAT pool. Changing this forces a new resource to be created.
  • frontendIpConfigurationName - (Required) The name of the frontend IP configuration exposing this rule.
  • protocol - (Required) The transport protocol for the external endpoint. Possible values are all, tcp and udp.
  • frontendPortStart - (Required) The first port number in the range of external ports that will be used to provide Inbound NAT to NICs associated with this Load Balancer. Possible values range between 1 and 65534, inclusive.
  • frontendPortEnd - (Required) The last port number in the range of external ports that will be used to provide Inbound NAT to NICs associated with this Load Balancer. Possible values range between 1 and 65534, inclusive.
  • backendPort - (Required) The port used for the internal endpoint. Possible values range between 1 and 65535, inclusive.
  • idleTimeoutInMinutes - (Optional) Specifies the idle timeout in minutes for TCP connections. Valid values are between 4 and 30. Defaults to 4.
  • floatingIpEnabled - (Optional) Are the floating IPs enabled for this Load Balancer Rule? A floating IP is reassigned to a secondary server in case the primary server fails. Required to configure a SQL AlwaysOn Availability Group.
  • tcpResetEnabled - (Optional) Is TCP Reset enabled for this Load Balancer Rule?

Attributes Reference

The following attributes are exported:

  • id - The ID of the Load Balancer NAT pool.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the Load Balancer NAT Pool.
  • update - (Defaults to 30 minutes) Used when updating the Load Balancer NAT Pool.
  • read - (Defaults to 5 minutes) Used when retrieving the Load Balancer NAT Pool.
  • delete - (Defaults to 30 minutes) Used when deleting the Load Balancer NAT Pool.

Import

Load Balancer NAT Pools can be imported using the resourceId, e.g.

terraform import azurerm_lb_nat_pool.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/loadBalancers/lb1/inboundNatPools/pool1