Complete the code to create a basic Azure Load Balancer resource.
resource "azurerm_lb" "example" { name = "example-lb" location = "eastus" resource_group_name = "example-resources" sku = "[1]" }
The Basic SKU is the simplest Azure Load Balancer type, suitable for small workloads.
Complete the code to specify the frontend IP configuration for the load balancer.
resource "azurerm_lb" "example" { name = "example-lb" location = "eastus" resource_group_name = "example-resources" sku = "Basic" frontend_ip_configuration { name = "PublicIPAddress" public_ip_address_id = azurerm_public_ip.example.[1] } }
The id property is used to reference the public IP resource in Azure.
Fix the error in the backend address pool configuration by completing the code.
resource "azurerm_lb_backend_address_pool" "example" { name = "example-backend-pool" loadbalancer_id = azurerm_lb.example.[1] }
The backend address pool needs the load balancer's id to link correctly.
Fill both blanks to configure a health probe for the load balancer.
resource "azurerm_lb_probe" "example" { name = "example-probe" loadbalancer_id = azurerm_lb.example.[1] protocol = "[2]" port = 80 }
The health probe requires the load balancer's id and the protocol, here Http, to check service health.
Fill all three blanks to define a load balancing rule.
resource "azurerm_lb_rule" "example" { name = "example-rule" resource_group_name = "example-resources" loadbalancer_id = azurerm_lb.example.[1] frontend_ip_configuration_name = azurerm_lb.example.frontend_ip_configuration[0].[2] backend_address_pool_ids = [azurerm_lb_backend_address_pool.example.[3]] protocol = "Tcp" frontend_port = 80 backend_port = 80 enable_floating_ip = false idle_timeout_in_minutes = 4 }
The load balancing rule needs the load balancer's id, the frontend IP configuration's name, and the backend address pool's id to connect all parts correctly.