-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-balancer.tf
67 lines (61 loc) · 2.36 KB
/
load-balancer.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
60
61
62
63
64
65
66
67
# create a public ip
resource "azurerm_public_ip" "frontend" {
name = "tf-public-ip"
location = "${var.arm_region}"
resource_group_name = "${var.arm_resource_group_name}"
allocation_method = "Static"
}
# create a load balancer
resource "azurerm_lb" "frontend" {
name = "tf-lb"
location = "${var.arm_region}"
resource_group_name = "${var.arm_resource_group_name}"
frontend_ip_configuration {
name = "default"
public_ip_address_id = "${azurerm_public_ip.frontend.id}"
private_ip_address_allocation = "dynamic"
}
}
# create a load balancer probe PORT 80
resource "azurerm_lb_probe" "port80" {
name = "tf-lb-probe-80"
loadbalancer_id = "${azurerm_lb.frontend.id}"
protocol = "Http"
request_path = "/"
port = 80
}
# create a load balancer rule PORT 80
resource "azurerm_lb_rule" "port80" {
name = "tf-lb-rule-80"
loadbalancer_id = "${azurerm_lb.frontend.id}"
backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.frontend.id}"]
probe_id = "${azurerm_lb_probe.port80.id}"
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "default"
}
# load balancer probe PORT 443
resource "azurerm_lb_probe" "port443" {
name = "tf-lb-probe-443"
loadbalancer_id = "${azurerm_lb.frontend.id}"
protocol = "Http"
request_path = "/"
port = 443
}
# load balancer rule PORT 443
resource "azurerm_lb_rule" "port443" {
name = "tf-lb-rule-443"
loadbalancer_id = "${azurerm_lb.frontend.id}"
backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.frontend.id}"]
probe_id = "${azurerm_lb_probe.port443.id}"
protocol = "Tcp"
frontend_port = 443
backend_port = 443
frontend_ip_configuration_name = "default"
}
# load balancer backend address pool
resource "azurerm_lb_backend_address_pool" "frontend" {
name = "tf-lb-pool"
loadbalancer_id = "${azurerm_lb.frontend.id}"
}