Azure Load Balancer Outbound Rule
This page shows how to write Terraform and Azure Resource Manager for Load Balancer Outbound Rule and write them securely.
azurerm_lb_outbound_rule (Terraform)
The Outbound Rule in Load Balancer can be configured in Terraform with the resource name azurerm_lb_outbound_rule
. The following sections describe 9 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_lb_outbound_rule" "LB1outboundrule1356" {
resource_group_name = azurerm_resource_group.TESTlab.name
loadbalancer_id = azurerm_lb.LB1.id
name = "LB1outboundrule1356"
protocol = "Tcp"
backend_address_pool_id = azurerm_lb_backend_address_pool.LB1backendPool1356.id
resource "azurerm_lb_outbound_rule" "example" {
resource_group_name = module.resource_group.azurerm_resource_group.example.name
loadbalancer_id = module.load_balance.azurerm_lb.example.id
name = var.name
protocol = var.protocol
backend_address_pool_id = module.backend_address_poolazurerm_lb_backend_address_pool.example.id
resource "azurerm_lb_outbound_rule" "region_01_load_balancer_01_outbound_rule_01" {
resource_group_name = azurerm_resource_group.region_01.name
loadbalancer_id = azurerm_lb.region_01_load_balancer_01.id
name = "OutboundRule"
protocol = "All"
backend_address_pool_id = azurerm_lb_backend_address_pool.region_01_load_balancer_01_backend_address_pool_01.id
resource "azurerm_lb_outbound_rule" "region_02_load_balancer_01_outbound_rule_01" {
resource_group_name = azurerm_resource_group.region_02.name
loadbalancer_id = azurerm_lb.region_02_load_balancer_01.id
name = "OutboundRule"
protocol = "All"
backend_address_pool_id = azurerm_lb_backend_address_pool.region_02_load_balancer_01_backend_address_pool_01.id
resource "azurerm_lb_outbound_rule" "this" {
allocated_outbound_ports = var.allocated_outbound_ports
backend_address_pool_id = var.backend_address_pool_id
enable_tcp_reset = var.enable_tcp_reset
idle_timeout_in_minutes = var.idle_timeout_in_minutes
loadbalancer_id = var.loadbalancer_id
resource "azurerm_lb_outbound_rule" "example" {
resource_group_name = azurerm_resource_group.example.name
loadbalancer_id = azurerm_lb.example.id
name = "OutboundRule"
protocol = "Tcp"
backend_address_pool_id = azurerm_lb_backend_address_pool.example.id
resource "azurerm_lb_outbound_rule" "rules" {
resource_group_name = azurerm_resource_group.example.name
loadbalancer_id = azurerm_lb.example.id
name = "OutboundRule"
protocol = "Tcp"
backend_address_pool_id = azurerm_lb_backend_address_pool.example.id
resource "azurerm_lb_outbound_rule" "lbout" {
resource_group_name = azurerm_resource_group.rg.name
loadbalancer_id = azurerm_lb.lb.id
name = "outboundRule"
protocol = "All"
backend_address_pool_id = azurerm_lb_backend_address_pool.bpepool.id
resource "azurerm_lb_outbound_rule" "this" {
allocated_outbound_ports = var.allocated_outbound_ports
backend_address_pool_id = var.backend_address_pool_id
enable_tcp_reset = var.enable_tcp_reset
idle_timeout_in_minutes = var.idle_timeout_in_minutes
loadbalancer_id = var.loadbalancer_id
Parameters
-
allocated_outbound_ports
optional - number -
backend_address_pool_id
required - string -
enable_tcp_reset
optional - bool -
id
optional computed - string -
idle_timeout_in_minutes
optional - number -
loadbalancer_id
required - string -
name
required - string -
protocol
required - string -
resource_group_name
required - string -
frontend_ip_configuration
list block -
timeouts
single block
Explanation in Terraform Registry
Manages a Load Balancer Outbound Rule.
NOTE When using this resource, the Load Balancer needs to have a FrontEnd IP Configuration and a Backend Address Pool Attached.
Microsoft.Network/loadBalancers (Azure Resource Manager)
The loadBalancers in Microsoft.Network can be configured in Azure Resource Manager with the resource name Microsoft.Network/loadBalancers
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
"type": "Microsoft.Network/loadBalancers",
"location": "southcentralus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f62dd440-2673-4f36-8e59-fcbdeb4a5959",
"frontendIPConfigurations": [
Parameters
name
required - stringtype
required - stringapiVersion
required - stringlocation
required - stringResource location.
tags
optional - stringResource tags.
extendedLocation
optionalname
required - stringThe name of the extended location.
type
required - stringThe type of the extended location.
sku
optionalname
optional - stringName of a load balancer SKU.
tier
optional - stringTier of a load balancer SKU.
properties
requiredfrontendIPConfigurations
optional arrayproperties
optionalprivateIPAddress
optional - stringThe private IP address of the IP configuration.
privateIPAllocationMethod
optional - stringThe Private IP allocation method.
privateIPAddressVersion
optional - stringWhether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4.
subnet
optionalid
required - stringResource ID.
publicIPAddress
optionalid
required - stringResource ID.
publicIPPrefix
optionalid
required - stringResource ID.
name
required - stringThe name of the resource that is unique within the set of frontend IP configurations used by the load balancer. This name can be used to access the resource.
zones
optional - arrayA list of availability zones denoting the IP allocated for the resource needs to come from.
backendAddressPools
optional arrayproperties
optionallocation
optional - stringThe location of the backend address pool.
loadBalancerBackendAddresses
optional arrayproperties
optionalvirtualNetwork
optionalid
required - stringResource ID.
subnet
optionalid
required - stringResource ID.
ipAddress
optional - stringIP Address belonging to the referenced virtual network.
loadBalancerFrontendIPConfiguration
optionalid
required - stringResource ID.
name
optional - stringName of the backend address.
name
required - stringThe name of the resource that is unique within the set of backend address pools used by the load balancer. This name can be used to access the resource.
loadBalancingRules
optional arrayproperties
optionalfrontendIPConfiguration
requiredid
required - stringResource ID.
backendAddressPool
optionalid
required - stringResource ID.
probe
optionalid
required - stringResource ID.
protocol
required - stringThe reference to the transport protocol used by the load balancing rule.
loadDistribution
optional - stringThe load distribution policy for this rule.
frontendPort
required - integerThe port for the external endpoint. Port numbers for each rule must be unique within the Load Balancer. Acceptable values are between 0 and 65534. Note that value 0 enables "Any Port".
backendPort
required - integerThe port used for internal connections on the endpoint. Acceptable values are between 0 and 65535. Note that value 0 enables "Any Port".
idleTimeoutInMinutes
optional - integerThe timeout for the TCP idle connection. The value can be set between 4 and 30 minutes. The default value is 4 minutes. This element is only used when the protocol is set to TCP.
enableFloatingIP
optional - booleanConfigures a virtual machine's endpoint for the floating IP capability required to configure a SQL AlwaysOn Availability Group. This setting is required when using the SQL AlwaysOn Availability Groups in SQL server. This setting can't be changed after you create the endpoint.
enableTcpReset
optional - booleanReceive bidirectional TCP Reset on TCP flow idle timeout or unexpected connection termination. This element is only used when the protocol is set to TCP.
disableOutboundSnat
optional - booleanConfigures SNAT for the VMs in the backend pool to use the publicIP address specified in the frontend of the load balancing rule.
name
required - stringThe name of the resource that is unique within the set of load balancing rules used by the load balancer. This name can be used to access the resource.
probes
optional arrayproperties
optionalprotocol
required - stringThe protocol of the end point. If 'Tcp' is specified, a received ACK is required for the probe to be successful. If 'Http' or 'Https' is specified, a 200 OK response from the specifies URI is required for the probe to be successful.
port
required - integerThe port for communicating the probe. Possible values range from 1 to 65535, inclusive.
intervalInSeconds
optional - integerThe interval, in seconds, for how frequently to probe the endpoint for health status. Typically, the interval is slightly less than half the allocated timeout period (in seconds) which allows two full probes before taking the instance out of rotation. The default value is 15, the minimum value is 5.
numberOfProbes
required - integerThe number of probes where if no response, will result in stopping further traffic from being delivered to the endpoint. This values allows endpoints to be taken out of rotation faster or slower than the typical times used in Azure.
requestPath
optional - stringThe URI used for requesting health status from the VM. Path is required if a protocol is set to http. Otherwise, it is not allowed. There is no default value.
name
required - stringThe name of the resource that is unique within the set of probes used by the load balancer. This name can be used to access the resource.
inboundNatRules
optional arrayproperties
optionalfrontendIPConfiguration
requiredid
required - stringResource ID.
protocol
required - stringThe reference to the transport protocol used by the load balancing rule.
frontendPort
required - integerThe port for the external endpoint. Port numbers for each rule must be unique within the Load Balancer. Acceptable values range from 1 to 65534.
backendPort
required - integerThe port used for the internal endpoint. Acceptable values range from 1 to 65535.
idleTimeoutInMinutes
optional - integerThe timeout for the TCP idle connection. The value can be set between 4 and 30 minutes. The default value is 4 minutes. This element is only used when the protocol is set to TCP.
enableFloatingIP
optional - booleanConfigures a virtual machine's endpoint for the floating IP capability required to configure a SQL AlwaysOn Availability Group. This setting is required when using the SQL AlwaysOn Availability Groups in SQL server. This setting can't be changed after you create the endpoint.
enableTcpReset
optional - booleanReceive bidirectional TCP Reset on TCP flow idle timeout or unexpected connection termination. This element is only used when the protocol is set to TCP.
name
required - stringThe name of the resource that is unique within the set of inbound NAT rules used by the load balancer. This name can be used to access the resource.
inboundNatPools
optional arrayproperties
optionalfrontendIPConfiguration
requiredid
required - stringResource ID.
protocol
required - stringThe reference to the transport protocol used by the inbound NAT pool.
frontendPortRangeStart
required - integerThe first port number in the range of external ports that will be used to provide Inbound Nat to NICs associated with a load balancer. Acceptable values range between 1 and 65534.
frontendPortRangeEnd
required - integerThe last port number in the range of external ports that will be used to provide Inbound Nat to NICs associated with a load balancer. Acceptable values range between 1 and 65535.
backendPort
required - integerThe port used for internal connections on the endpoint. Acceptable values are between 1 and 65535.
idleTimeoutInMinutes
optional - integerThe timeout for the TCP idle connection. The value can be set between 4 and 30 minutes. The default value is 4 minutes. This element is only used when the protocol is set to TCP.
enableFloatingIP
optional - booleanConfigures a virtual machine's endpoint for the floating IP capability required to configure a SQL AlwaysOn Availability Group. This setting is required when using the SQL AlwaysOn Availability Groups in SQL server. This setting can't be changed after you create the endpoint.
enableTcpReset
optional - booleanReceive bidirectional TCP Reset on TCP flow idle timeout or unexpected connection termination. This element is only used when the protocol is set to TCP.
name
required - stringThe name of the resource that is unique within the set of inbound NAT pools used by the load balancer. This name can be used to access the resource.
outboundRules
optional arrayproperties
optionalallocatedOutboundPorts
optional - integerThe number of outbound ports to be used for NAT.
frontendIPConfigurations
required arrayid
required - stringResource ID.
backendAddressPool
requiredid
required - stringResource ID.
protocol
required - stringThe protocol for the outbound rule in load balancer.
enableTcpReset
optional - booleanReceive bidirectional TCP Reset on TCP flow idle timeout or unexpected connection termination. This element is only used when the protocol is set to TCP.
idleTimeoutInMinutes
optional - integerThe timeout for the TCP idle connection.
name
optional - stringThe name of the resource that is unique within the set of outbound rules used by the load balancer. This name can be used to access the resource.
Frequently asked questions
What is Azure Load Balancer Outbound Rule?
Azure Load Balancer Outbound Rule is a resource for Load Balancer of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Load Balancer Outbound Rule?
For Terraform, the nzebar/Terraform, VentsislavDinev/en_sample and ardacetinkaya/terraform-azure-vm-scale-set source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the LRuttenCN/cloud-custodian, LRuttenCN/cloud-custodian and harsh4870/cloud-custodian source code examples are useful. See the Azure Resource Manager Example section for further details.