Azure Load Balancer Terraform Module
A terraform module to provide load balancers in Azure.
Public loadbalancer example:
resource "azurerm_resource_group" "main" {
name = var. resource_group_name
location = " westus"
tags = {
environment = " nonprod"
costcenter = " 12345"
ppm = " N/A"
fgid = " 1234"
appname = " myapp"
}
}
module "public-lb" {
source = " highwayoflife/terraform-azurerm-load-balancer"
type = " Public"
resource_group_name = azurerm_resource_group. main . name
prefix = " terraform-test"
remote_port = {
ssh = [" Tcp" , " 22" ]
}
lb_port = {
http = [" 443" , " Tcp" , " 443" ]
}
depends_on = {
azurerm_resource_group.main
}
}
Private Load Balancer Example:
resource "azurerm_resource_group" "group" {
name = var. resource_group_name
location = " westus"
tags = {
environment = " nonprod"
costcenter = " 12345"
ppm = " N/A"
fgid = " 1234"
appname = " myapp"
}
}
data "azurerm_subnet" "subnet" {
name = var. subnet_name
virtual_network_name = var. vnet_name
resource_group_name = var. vnet_resource_group_name
}
module "private-lb" {
source = " highwayoflife/terraform-azurerm-load-balancer"
type = " private"
prefix = " MyTerraformLB"
resource_group_name = azurerm_resource_group. rg . name
subnet_id = data. azurerm_subnet . subnet . id
# Define a static IP, if empty or not defined, IP will be dynamic
private_ip_address = " 10.0.1.6"
remote_port = {
ssh = [" Tcp" , " 22" ]
}
lb_port = {
https = [" 443" , " Tcp" , " 443" ]
}
depends_on = {
azurerm_resource_group.group
}
}
No modules.
Name
Description
Type
Default
Required
prefix
(Required) Default prefix to use with your resource names.
string
n/a
yes
resource_group_name
(Required) The name of the existing resource group where the load balancer resources will be placed.
string
n/a
yes
frontend_name
(Optional) Specifies the name of the frontend ip configuration.
string
"FrontendIP"
no
lb_port
Protocols to be used for lb health probes and rules. [frontend_port, protocol, backend_port]
map(list(string))
{}
no
lb_probe_interval
Interval in seconds the load balancer health probe rule does a check
number
5
no
lb_probe_unhealthy_threshold
(Optional) Number of times the load balancer health probe has an unsuccessful attempt before considering the endpoint unhealthy. Default = 2.
number
2
no
location
(Optional) The location/region where the load balancer will be created. If not provided, will use the location of the resource group.
string
""
no
private_ip_address
(Optional) Private ip address to assign to frontend. Use it with type = private
string
""
no
remote_port
Protocols to be used for remote vm access. [protocol, backend_port]. Frontend port will be automatically generated starting at 50000 and in the output.
map(list(string))
{}
no
subnet_id
(Optional) Frontend subnet id to use when in private mode
string
""
no
tags
(optional) Tags to use in addition to tags assigned to the resource group.
map(string)
{ "source": "terraform" }
no
type
(Optional) Defined if the loadbalancer is private or public. Default private.
string
"private"
no
MIT