A terraform module to provide load balancers in Azure.
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
}
}
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
}
}
Name | Version |
---|---|
terraform | >= 0.13 |
Name | Version |
---|---|
azurerm | n/a |
No modules.
Name | Type |
---|---|
azurerm_lb.lb | resource |
azurerm_lb_backend_address_pool.azlb | resource |
azurerm_lb_nat_rule.azlb | resource |
azurerm_lb_probe.azlb | resource |
azurerm_lb_rule.azlb | resource |
azurerm_public_ip.ip | resource |
azurerm_resource_group.group | data source |
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) |
{ |
no |
type | (Optional) Defined if the loadbalancer is private or public. Default private. | string |
"private" |
no |
Name | Description |
---|---|
lb_backend_address_pool_id | The id for the azurerm_lb_backend_address_pool resource |
lb_frontend_ip_configuration | The frontend_ip_configuration for the azurerm_lb resource |
lb_id | The id for the azurerm_lb resource |
lb_nat_rule_ids | The ids for the azurerm_lb_nat_rule resources |
lb_private_ip_address | The first private IP address assigned to the load balancer in frontend_ip_configuration blocks, if any. |
lb_probe_ids | The ids for the azurerm_lb_probe resources |
public_ip_address | The ip address for the azurerm_lb_public_ip resource |
public_ip_id | The id for the azurerm_lb_public_ip resource |
- David Lewis
- Originally based on terraform-azurerm-loadbalancer by David Tesar