Skip to content

This terraform module is designed to create Azure Load-balancer resources. Load-balancing options - Azure Architecture Center ... Azure Load Balancer is a high-performance, ultra low-latency Layer 4 load-balancing service (inbound and outbound) for all UDP and TCP protocols.

License

Notifications You must be signed in to change notification settings

clouddrove/terraform-azure-load-balancer

Terraform AZURE LOAD-BALANCER

Terraform module to create LOAD-BALANCER resource on AZURE.

Terraform Licence


We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.

This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.

Prerequisites

This module has a few dependencies:

Examples

IMPORTANT: Since the master branch used in source varies based on new modifications, we suggest that you use the release versions here.

Simple Example

Here is an example of how you can use this module in your inventory structure:

module "load-balancer" {
  source      = "clouddrove/load-balancer/azure"
  version     = "1.0.0"
  name        = "example"
  environment = "test"
  label_order = ["name","environment"]
 
  #   Common
  ip_count            = 1
  enabled             = true
  resource_group_name = module.resource_group.resource_group_name
  location            = module.resource_group.resource_group_location

  # Existing Network Interface
  network_interace_id = "" ## If Existing Network Interface is allocated then assign value here. e.g. azurerm_network_interface.default[0].id ,azurerm_virtual_machine.example.network_interface_ids[0]

  # Load Balancer
  frontend_name                          = "mypublicIP"
  frontend_private_ip_address_allocation = "Static"
  frontend_private_ip_address            = "10.0.1.6"
  lb_sku                                 = "Standard"

  #   Public IP
  allocation_method = "Static"
  sku               = "Standard"
  nat_protocol      = "Tcp"
  public_ip_enabled = true
  ip_version        = "IPv4"

  # Backend Pool
  is_enable_backend_pool              = false
  network_interaface_id_association   = ""
  ip_configuration_name_association   = ""

  remote_port = {
    ssh = ["Tcp", "22"]
  }

  lb_port = {
    http  = ["80", "Tcp", "80"]
    https = ["443", "Tcp", "443"]
  }

  lb_probe = {
    http  = ["Tcp", "80", ""]
    http2 = ["Http", "1443", "/"]
  }

  depends_on = [module.resource_group]
}

Inputs

Name Description Type Default Required
allocation_method Defines the allocation method for this IP address. Possible values are Static or Dynamic. string "" no
application Application (e.g. cd or clouddrove). string "" no
backendpoolname (Required) Specifies the name of the Backend Address Pool. Changing this forces a new resource to be created. string "test-backendpool" no
create Used when creating the Resource Group. string "60m" no
ddos_protection_mode (Optional) The DDoS protection mode of the public IP. Possible values are Disabled, Enabled, and VirtualNetworkInherited. Defaults to VirtualNetworkInherited. string "VirtualNetworkInherited" no
delete Used when deleting the Resource Group. string "60m" no
domain_name_label Label for the Domain Name. Will be used to make up the FQDN. If a domain name label is specified, an A DNS record is created for the public IP in the Microsoft Azure DNS system. string null no
edge_zone (Optional) Specifies the Edge Zone within the Azure Region where this Public IP and Load Balancer should exist. Changing this forces new resources to be created. string null no
enabled Flag to control the module creation. bool false no
environment Environment (e.g. prod, dev, staging). string "" no
frontend_name (Required) Specifies the name of the frontend ip configuration. string "myip" no
frontend_private_ip_address (Optional) Private ip address to assign to frontend. Use it with type = private string "" no
frontend_private_ip_address_allocation (Optional) Frontend ip allocation type (Static or Dynamic) string "Dynamic" no
frontend_private_ip_address_version (Optional) The version of IP that the Private IP Address is. Possible values are IPv4 or IPv6. string null no
frontend_subnet_id (Optional) Frontend subnet id to use when in private mode string "" no
idle_timeout_in_minutes Specifies the timeout for the TCP idle connection. The value can be set between 4 and 60 minutes. number 10 no
ip_configuration_name_association (Required) Ip Configuration name for Network Interaface Association with Load Balancer. list(string)
[
""
]
no
ip_count Number of Public IP Addresses to create. number 0 no
ip_version The IP Version to use, IPv6 or IPv4. string "" no
is_enable_backend_pool Backend Pool Configuration for the Load Balancer. bool false no
label_order Label order, e.g. name,application. list(any)
[
"name",
"environment"
]
no
lb_port Protocols to be used for lb rules. Format as [frontend_port, protocol, backend_port] map(any) {} no
lb_probe (Optional) Protocols to be used for lb health probes. Format as [protocol, port, request_path] map(any) {} no
lb_probe_interval Interval in seconds the load balancer health probe rule does a check number 5 no
lb_probe_unhealthy_threshold Number of times the load balancer health probe has an unsuccessful attempt before considering the endpoint unhealthy. number 2 no
lb_sku (Optional) The SKU of the Azure Load Balancer. Accepted values are Basic and Standard. string "Basic" no
location Location where resource should be created. string "" no
managedby ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. string "anmol@clouddrove.com" no
name Name (e.g. app or cluster). string "" no
nat_protocol (Required) The protocol of Load Balancer's NAT rule. string "Tcp" no
net_count Number of network Addresses to create. number 0 no
network_interaface_id_association (Required) Network Interaface id for Network Interface Association with Load Balancer. list(string)
[
""
]
no
public_ip_enabled Whether public IP is enabled. bool false no
public_ip_prefix_id If specified then public IP address allocated will be provided from the public IP prefix resource. string null no
read Used when retrieving the Resource Group. string "5m" 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(any) {} no
repository Terraform current module repo string "" no
resource_group_name The name of the resource group in which to create the virtual network. string "" no
reverse_fqdn A fully qualified domain name that resolves to this public IP address. If the reverseFqdn is specified, then a PTR DNS record is created pointing from the IP address in the in-addr.arpa domain to the reverse FQDN. string "" no
sku The SKU of the Public IP. Accepted values are Basic and Standard. Defaults to Basic. string "Basic" no
tags Additional tags (e.g. map(BusinessUnit,XYZ). map(any) {} no
update Used when updating the Resource Group. string "60m" no
zones A collection containing the availability zone to allocate the Public IP in. list(any) null no

Outputs

Name Description
azurerm_lb_backend_address_pool_id the id for the azurerm_lb_backend_address_pool resource
azurerm_lb_frontend_ip_configuration the frontend_ip_configuration for the azurerm_lb resource
azurerm_lb_id the id for the azurerm_lb resource
azurerm_lb_nat_rule_ids the ids for the azurerm_lb_nat_rule resources
azurerm_lb_probe_ids the ids for the azurerm_lb_probe resources
azurerm_public_ip_address the ip address for the azurerm_lb_public_ip resource
azurerm_public_ip_id the id for the azurerm_lb_public_ip resource

Testing

In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.

You need to run the following command in the testing folder:

  go test -run Test

Feedback

If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at hello@clouddrove.com.

If you have found it worth your time, go ahead and give us a ★ on our GitHub!

About us

At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

We are The Cloud Experts!


We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.

About

This terraform module is designed to create Azure Load-balancer resources. Load-balancing options - Azure Architecture Center ... Azure Load Balancer is a high-performance, ultra low-latency Layer 4 load-balancing service (inbound and outbound) for all UDP and TCP protocols.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published