azurermLbRule
Manages a Load Balancer Rule.
\~> 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: "West US",
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: "West US",
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 azurermLbRuleExample = new azurerm.lbRule.LbRule(this, "example_3", {
backend_port: 3389,
frontend_ip_configuration_name: "PublicIPAddress",
frontend_port: 3389,
loadbalancer_id: azurermLbExample.id,
name: "LBRule",
protocol: "Tcp",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLbRuleExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
name
- (Required) Specifies the name of the LB Rule. Changing this forces a new resource to be created.loadbalancerId
- (Required) The ID of the Load Balancer in which to create the Rule. Changing this forces a new resource to be created.frontendIpConfigurationName
- (Required) The name of the frontend IP configuration to which the rule is associated.protocol
- (Required) The transport protocol for the external endpoint. Possible values aretcp
,udp
orall
.frontendPort
- (Required) The port for the external endpoint. Port numbers for each Rule must be unique within the Load Balancer. Possible values range between 0 and 65534, inclusive.backendPort
- (Required) The port used for internal connections on the endpoint. Possible values range between 0 and 65535, inclusive.backendAddressPoolIds
- (Optional) A list of reference to a Backend Address Pool over which this Load Balancing Rule operates.
\~> NOTE: In most cases users can only set one Backend Address Pool ID in the backendAddressPoolIds
. Especially, when the sku of the LB is gateway
, users can set up to two IDs in the backendAddressPoolIds
.
probeId
- (Optional) A reference to a Probe used by this Load Balancing Rule.enableFloatingIp
- (Optional) Are the Floating IPs enabled for this Load Balncer Rule? A "floating” IP is reassigned to a secondary server in case the primary server fails. Required to configure a SQL AlwaysOn Availability Group. Defaults tofalse
.idleTimeoutInMinutes
- (Optional) Specifies the idle timeout in minutes for TCP connections. Valid values are between4
and30
minutes. Defaults to4
minutes.loadDistribution
- (Optional) Specifies the load balancing distribution type to be used by the Load Balancer. Possible values are:default
– The load balancer is configured to use a 5 tuple hash to map traffic to available servers.sourceIp
– The load balancer is configured to use a 2 tuple hash to map traffic to available servers.sourceIpProtocol
– The load balancer is configured to use a 3 tuple hash to map traffic to available servers. Also known as Session Persistence, where the options are callednone
,clientIp
andclientIpAndProtocol
respectively.disableOutboundSnat
- (Optional) Is snat enabled for this Load Balancer Rule? Defaultfalse
.enableTcpReset
- (Optional) Is TCP Reset enabled for this Load Balancer Rule?
Attributes Reference
The following attributes are exported:
id
- The ID of the Load Balancer Rule.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the Load Balancer Rule.update
- (Defaults to 30 minutes) Used when updating the Load Balancer Rule.read
- (Defaults to 5 minutes) Used when retrieving the Load Balancer Rule.delete
- (Defaults to 30 minutes) Used when deleting the Load Balancer Rule.
Import
Load Balancer Rules can be imported using the resourceId
, e.g.