-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeb-Loadbalancer.tf
More file actions
55 lines (46 loc) · 2.22 KB
/
Copy pathWeb-Loadbalancer.tf
File metadata and controls
55 lines (46 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
resource "azurerm_lb" "web_load_balancer" {
name = "lb-webapp-${var.resource_grp_name}"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
sku = "Standard"
frontend_ip_configuration {
name = "LoadBalancerFrontEnd"
public_ip_address_id = azurerm_public_ip.public_ip.id
}
tags = {
environment = "dev"
}
}
resource "azurerm_lb_probe" "web_load_balancer_probe" {
name = "webapp-probe"
loadbalancer_id = azurerm_lb.web_load_balancer.id
protocol = "Tcp"
port = 80
// path = "/" <--- Uncomment if using HTTP/S probes. Make it match your web server's health check endpoint. Make to path match your web server's index page or health check endpoint.
//body = "Username: admin, Password: P@ssw0rd1234" <--- Uncomment if you want to send a specific body in the probe request.
// resource_group_name = azurerm_resource_group.rg.name
}
resource "azurerm_lb_backend_address_pool" "web_load_balancer_backend" {
name = "webapp-backend-pool"
loadbalancer_id = azurerm_lb.web_load_balancer.id
virtual_network_id = var.Vnet.MainVnet.id
}
resource "azurerm_lb_rule" "web_load_balancer_rule" {
name = "webapp-rule"
loadbalancer_id = azurerm_lb.web_load_balancer.id
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = azurerm_lb.web_load_balancer.frontend_ip_configuration[0].name
backend_address_pool_ids = azurerm_lb_backend_address_pool.web_load_balancer_backend[0].id
probe_id = azurerm_lb_probe.web_load_balancer_probe.id
}
/// Load balancer associated with the web subnet
/*
resource "azurerm_network_interface_backend_address_pool_association" "web_subnet_association" {
count = length(azurerm_network_interface.web_subnet_nic)
network_interface_id = azurerm_network_interface.web_subnet_nic[count.index].id
ip_configuration_name = "ipconfig1" //IP configuration name in the NIC # This should match the name of the IP configuration in the NIC
backend_address_pool_id = azurerm_lb_backend_address_pool.web_load_balancer_backend.id
}
*/