-
Notifications
You must be signed in to change notification settings - Fork 3
/
network.tf
65 lines (53 loc) · 1.38 KB
/
network.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
resource "digitalocean_vpc" "main" {
name = "${var.prefix}-${var.region}-vpc"
region = var.region
}
resource "digitalocean_loadbalancer" "lb" {
name = "${var.prefix}-lb"
droplet_tag = var.tag-name
vpc_uuid = digitalocean_vpc.main.id
region = var.region
size_unit = var.lb-count
forwarding_rule {
entry_port = 80
entry_protocol = "tcp"
target_port = 3128
target_protocol = "tcp"
}
healthcheck {
protocol = "tcp"
port = 3128
}
}
resource "digitalocean_firewall" "slave-lb-firewall" {
name = "${var.prefix}-fw"
tags = [var.tag-name]
inbound_rule {
protocol = "tcp"
port_range = "22"
source_addresses = ["0.0.0.0/0", "::/0"]
}
inbound_rule {
protocol = "tcp"
port_range = "all"
source_load_balancer_uids = [digitalocean_loadbalancer.lb.id]
}
outbound_rule {
destination_addresses = ["0.0.0.0/0", "::/0"]
protocol = "tcp"
port_range = "all"
}
outbound_rule {
destination_addresses = ["0.0.0.0/0", "::/0"]
protocol = "udp"
port_range = "all"
}
outbound_rule {
destination_addresses = ["0.0.0.0/0", "::/0"]
protocol = "icmp"
}
}
output "lb-ip" {
description = "IP Address of the load balancer"
value = digitalocean_loadbalancer.lb.ip
}