Skip to content

azurermNetworkInterfaceNatRuleAssociation

Manages the association between a Network Interface and a Load Balancer's NAT Rule.

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 azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
  this,
  "example_1",
  {
    address_space: ["10.0.0.0/16"],
    location: azurermResourceGroupExample.location,
    name: "example-network",
    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.*/
azurermVirtualNetworkExample.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,
  }
);
/*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 azurermSubnetExample = new azurerm.subnet.Subnet(this, "example_3", {
  address_prefixes: ["10.0.2.0/24"],
  name: "internal",
  resource_group_name: azurermResourceGroupExample.name,
  virtual_network_name: azurermVirtualNetworkExample.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.*/
azurermSubnetExample.overrideLogicalId("example");
const azurermLbExample = new azurerm.lb.Lb(this, "example_4", {
  frontend_ip_configuration: [
    {
      name: "primary",
      public_ip_address_id: azurermPublicIpExample.id,
    },
  ],
  location: azurermResourceGroupExample.location,
  name: "example-lb",
  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 azurermLbNatRuleExample = new azurerm.lbNatRule.LbNatRule(
  this,
  "example_5",
  {
    backend_port: 3389,
    frontend_ip_configuration_name: "primary",
    frontend_port: 3389,
    loadbalancer_id: azurermLbExample.id,
    name: "RDPAccess",
    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.*/
azurermLbNatRuleExample.overrideLogicalId("example");
const azurermNetworkInterfaceExample =
  new azurerm.networkInterface.NetworkInterface(this, "example_6", {
    ip_configuration: [
      {
        name: "testconfiguration1",
        private_ip_address_allocation: "Dynamic",
        subnet_id: azurermSubnetExample.id,
      },
    ],
    location: azurermResourceGroupExample.location,
    name: "example-nic",
    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.*/
azurermNetworkInterfaceExample.overrideLogicalId("example");
const azurermNetworkInterfaceNatRuleAssociationExample =
  new azurerm.networkInterfaceNatRuleAssociation.NetworkInterfaceNatRuleAssociation(
    this,
    "example_7",
    {
      ip_configuration_name: "testconfiguration1",
      nat_rule_id: azurermLbNatRuleExample.id,
      network_interface_id: azurermNetworkInterfaceExample.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.*/
azurermNetworkInterfaceNatRuleAssociationExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • networkInterfaceId - (Required) The ID of the Network Interface. Changing this forces a new resource to be created.

  • ipConfigurationName - (Required) The Name of the IP Configuration within the Network Interface which should be connected to the NAT Rule. Changing this forces a new resource to be created.

  • natRuleId - (Required) The ID of the Load Balancer NAT Rule which this Network Interface 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 Network Interface and the Load Balancers NAT Rule.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the association between the Network Interface and the Load Balancers NAT Rule.
  • update - (Defaults to 30 minutes) Used when updating the association between the Network Interface and the Load Balancers NAT Rule.
  • read - (Defaults to 5 minutes) Used when retrieving the association between the Network Interface and the Load Balancers NAT Rule.
  • delete - (Defaults to 30 minutes) Used when deleting the association between the Network Interface and the Load Balancers NAT Rule.

Import

Associations between Network Interfaces and Load Balancer NAT Rule can be imported using the resourceId, e.g.

terraform import azurerm_network_interface_nat_rule_association.association1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkInterfaces/nic1/ipConfigurations/example|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/loadBalancers/lb1/inboundNatRules/rule1

-> NOTE: This ID is specific to Terraform - and is of the format {networkInterfaceId}/ipConfigurations/{ipConfigurationName}|{natRuleId}.