<- All Blueprints
Customizable templates for deploying cloud infrastructure

Azure Load Balancer

This blueprint creates an Azure Load Balancer with best practices in mind, such as defaulting to the 'Standard' SKU for enhanced features and security. It provides flexibility to configure either a public or internal Load Balancer by allowing users to specify the appropriate frontend IP configurations. The blueprint promotes the use of tagging for better resource management and organizes variables into logical groups to guide users—including those who may not be cloud infrastructure experts—through the essential and advanced settings.

Define and customize Blueprints to set what infrastructure configuration options are available to developers.

---
constants:
  __name: "{{ name }}_{{ __guid }}"
variables:
  name:
    desc: "Name of the Load Balancer."
    required: true
    group: Load Balancer Details
  resource_group_name:
    desc: "Name of the Resource Group."
    required: true
    group: Load Balancer Details
    links_to: resource.azurerm_resource_group.name
  location:
    desc: "Azure region where the Load Balancer will be created."
    required: true
    group: Load Balancer Details
    default: "eastus"
  sku:
    desc: "The SKU of the Load Balancer. Options are 'Basic' or 'Standard'."
    required: false
    group: Load Balancer Details
    default: "Standard"
  frontend_ip_configuration_name:
    desc: "Name of the frontend IP configuration."
    required: true
    group: Frontend IP Configuration
    default: "LoadBalancerFrontEnd"
  frontend_ip_configuration_type:
    desc: "Type of the frontend IP configuration. Options are 'Public' or 'Internal'."
    required: true
    group: Frontend IP Configuration
    default: "Public"
  public_ip_address_id:
    desc: "ID of the Public IP to associate with the Load Balancer (required for public Load Balancer)."
    required: false
    group: Frontend IP Configuration
    links_to: resource.azurerm_public_ip.id
  subnet_id:
    desc: "ID of the Subnet to associate with the Load Balancer (required for internal Load Balancer)."
    required: false
    group: Frontend IP Configuration
    links_to: resource.azurerm_subnet.id
  private_ip_address_allocation:
    desc: "Defines how a private IP address is assigned. Options are 'Dynamic' or 'Static'."
    required: false
    group: Frontend IP Configuration
    default: "Dynamic"
  backend_address_pools:
    group: Backend Address Pools
    required: false
  load_balancing_rules:
    group: Load Balancing Rules
    required: false
  probes:
    group: Probes
    required: false
  tags:
    group: Tags
    required: false
groups:
  Load Balancer Details:
    order: 1
    desc: "Basic settings for the Load Balancer."
  Frontend IP Configuration:
    order: 2
    desc: "Configuration of the frontend IP for the Load Balancer."
  Backend Address Pools:
    order: 3
    desc: "Define backend address pools."
  Load Balancing Rules:
    order: 4
    desc: "Define load balancing rules."
  Probes:
    order: 5
    desc: "Define health probes."
  Tags:
    order: 6
    desc: "Tags to assign to the Load Balancer."
---

resource "azurerm_lb" "__name" {
  name                = {{ name }}
  location            = {{ location }}
  resource_group_name = {{ resource_group_name }}
  sku                 = {{ sku }}

  frontend_ip_configuration {
    name = {{ frontend_ip_configuration_name }}

    public_ip_address_id = {{ public_ip_address_id | required: false }}
    subnet_id            = {{ subnet_id | required: false }}
    private_ip_address_allocation = {{ private_ip_address_allocation | required: false }}
  }

  {{# backend_address_pools }}
  backend_address_pool {
    name = {{ backend_address_pools.name | desc: "Name of the backend address pool." | required: true }}
  }
  {{/ backend_address_pools }}

  {{# load_balancing_rules }}
  load_balancing_rule {
    name                            = {{ load_balancing_rules.name | desc: "Name of the load balancing rule." | required: true }}
    protocol                        = {{ load_balancing_rules.protocol | desc: "Protocol for the rule. Options are 'Tcp', 'Udp', or 'All'." | required: true | default: "Tcp" }}
    frontend_port                   = {{ load_balancing_rules.frontend_port | desc: "Frontend port number." | required: true }}
    backend_port                    = {{ load_balancing_rules.backend_port | desc: "Backend port number." | required: true }}
    frontend_ip_configuration_name  = {{ frontend_ip_configuration_name }}
    backend_address_pool_name       = {{ load_balancing_rules.backend_address_pool_name | desc: "Name of the backend address pool to use." | required: true }}
    probe_name                      = {{ load_balancing_rules.probe_name | desc: "Name of the probe to use." | required: false }}
    enable_floating_ip              = {{ load_balancing_rules.enable_floating_ip | desc: "Enable floating IP." | required: false | default: false }}
    idle_timeout_in_minutes         = {{ load_balancing_rules.idle_timeout_in_minutes | desc: "Idle timeout in minutes." | required: false | default: 4 }}
    load_distribution               = {{ load_balancing_rules.load_distribution | desc: "Load distribution policy." | required: false | default: "Default" }}
  }
  {{/ load_balancing_rules }}

  {{# probes }}
  probe {
    name                = {{ probes.name | desc: "Name of the probe." | required: true }}
    protocol            = {{ probes.protocol | desc: "Protocol for the probe. Options are 'Http', 'Tcp'." | required: true | default: "Tcp" }}
    port                = {{ probes.port | desc: "Port number for the probe." | required: true }}
    request_path        = {{ probes.request_path | desc: "Request path for HTTP probes." | required: false }}
    interval_in_seconds = {{ probes.interval_in_seconds | desc: "Interval between probes in seconds." | required: false | default: 5 }}
    number_of_probes    = {{ probes.number_of_probes | desc: "Number of unsuccessful probes before considering the endpoint unhealthy." | required: false | default: 2 }}
  }
  {{/ probes }}

  tags = {
    Name = {{ name }}
    {{# tags }}
      {{ tags.key | required: false }} = {{ tags.value | required: false }}
    {{/ tags }}
  }
}

// Configures a Load Balancer with options for public or internal deployment. It encourages secure defaults by using the 'Standard' SKU and allowing configuration of frontend IP settings. Tags are included for resource identification and management, and variables are organized to assist users who may not be cloud infrastructure experts.
//
A form is created automatically that accepts inputs that you defined in the Blueprint.
After filling out the Blueprint form, Terraform is generated and a PR is automatically submitted.
What am I looking at?

Talk to a Human

See Resourcely in action and learn how it can help you secure and manage your cloud infrastructure today!