-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
70 lines (58 loc) · 2.27 KB
/
main.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
68
69
70
data azurerm_resource_group "this" {
name = var.azure_resource_group_name
}
resource "azurerm_public_ip" "this" {
count = var.use_external_lb ? 1 : 0
name = "api-lb-pub-ip"
location = var.region
resource_group_name = data.azurerm_resource_group.this.name
allocation_method = "Static"
}
resource "azurerm_lb" "public" {
count = var.use_external_lb ? 1 : 0
name = "api-lb"
location = var.region
resource_group_name = data.azurerm_resource_group.this.name
tags = var.tags
frontend_ip_configuration {
name = "api-lb-pub-ip"
public_ip_address_id = azurerm_public_ip.this[0].id
}
}
resource "azurerm_lb" "private" {
count = var.use_external_lb ? 0 : 1
name = "api-lb"
location = var.region
resource_group_name = data.azurerm_resource_group.this.name
tags = var.tags
frontend_ip_configuration {
name = "api-lb-pub-ip"
subnet_id = var.subnet_id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_lb_backend_address_pool" "this" {
loadbalancer_id = var.use_external_lb ? azurerm_lb.public[0].id : azurerm_lb.private[0].id
name = "BackendAddressPool"
resource_group_name = data.azurerm_resource_group.this.name
}
resource "azurerm_lb_probe" "node-synced" {
loadbalancer_id = var.use_external_lb ? azurerm_lb.public[0].id : azurerm_lb.private[0].id
name = "node-sync-hc"
port = 5500
protocol = "Http"
request_path = "/"
resource_group_name = data.azurerm_resource_group.this.name
}
resource "azurerm_lb_rule" "substrate-rpc" {
name = "substrateRPC"
loadbalancer_id = var.use_external_lb ? azurerm_lb.public[0].id : azurerm_lb.private[0].id
frontend_ip_configuration_name = "api-lb-pub-ip"
frontend_port = 9933
backend_address_pool_id = azurerm_lb_backend_address_pool.this.id
backend_port = 9933
probe_id = azurerm_lb_probe.node-synced.id
load_distribution = "SourceIPProtocol"
protocol = "Tcp"
resource_group_name = data.azurerm_resource_group.this.name
}