-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadbalancer.tf
60 lines (52 loc) · 2.12 KB
/
loadbalancer.tf
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
56
57
58
59
resource "azurerm_lb" "demo" {
name = "demo-loadbalancer"
sku = length(var.zones) == 0 ? "Basic" : "Standard" # Basic is free, but doesn't support Availability Zones
location = var.location
resource_group_name = azurerm_resource_group.demo.name
frontend_ip_configuration {
name = "PublicIPAddress"
public_ip_address_id = azurerm_public_ip.demo.id
}
}
resource "azurerm_public_ip" "demo" {
name = "demo-public-ip"
location = var.location
resource_group_name = azurerm_resource_group.demo.name
allocation_method = "Static"
domain_name_label = azurerm_resource_group.demo.name
sku = length(var.zones) == 0 ? "Basic" : "Standard"
}
resource "azurerm_lb_backend_address_pool" "bpepool" {
resource_group_name = azurerm_resource_group.demo.name
loadbalancer_id = azurerm_lb.demo.id
name = "BackEndAddressPool"
}
resource "azurerm_lb_nat_pool" "lbnatpool" {
resource_group_name = azurerm_resource_group.demo.name
name = "ssh"
loadbalancer_id = azurerm_lb.demo.id
protocol = "Tcp"
frontend_port_start = 50000
frontend_port_end = 50119
backend_port = 22
frontend_ip_configuration_name = "PublicIPAddress"
}
resource "azurerm_lb_probe" "demo" {
resource_group_name = azurerm_resource_group.demo.name
loadbalancer_id = azurerm_lb.demo.id
name = "http-probe"
protocol = "Http"
request_path = "/"
port = 80
}
resource "azurerm_lb_rule" "demo" {
resource_group_name = azurerm_resource_group.demo.name
loadbalancer_id = azurerm_lb.demo.id
name = "LBRule"
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "PublicIPAddress"
probe_id = azurerm_lb_probe.demo.id
backend_address_pool_id = azurerm_lb_backend_address_pool.bpepool.id
}