-
Notifications
You must be signed in to change notification settings - Fork 4
/
rules.tf
101 lines (92 loc) · 3.61 KB
/
rules.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
resource "digitalocean_firewall" "outbound-http" {
name = "${var.prefix}-http-outbound-fw"
droplet_ids = ["${var.droplet_ids}"]
tags = ["${var.tags}"]
# http/https connection
outbound_rule = [
{
protocol = "tcp"
port_range = "80"
destination_addresses = ["${var.allowed_outbound_http_addresses}"]
destination_tags = ["${var.allowed_outbound_http_tags}"]
destination_droplet_ids = ["${var.allowed_outbound_http_droplet_ids}"]
destination_load_balancer_uids = ["${var.allowed_outbound_http_load_balancer_uids}"]
},
{
protocol = "tcp"
port_range = "443"
destination_addresses = ["${var.allowed_outbound_https_addresses}"]
destination_tags = ["${var.allowed_outbound_https_tags}"]
destination_droplet_ids = ["${var.allowed_outbound_https_droplet_ids}"]
destination_load_balancer_uids = ["${var.allowed_outbound_https_load_balancer_uids}"]
},
]
}
resource "digitalocean_firewall" "outbound-dns" {
name = "${var.prefix}-dns-outbound-fw"
droplet_ids = ["${var.droplet_ids}"]
tags = ["${var.tags}"]
# DNS lookups
outbound_rule = [
{
protocol = "udp"
port_range = "53"
destination_addresses = ["${var.allowed_outbound_dns_addresses}"]
destination_tags = ["${var.allowed_outbound_dns_tags}"]
destination_droplet_ids = ["${var.allowed_outbound_dns_droplet_ids}"]
destination_load_balancer_uids = ["${var.allowed_outbound_dns_load_balancer_uids}"]
},
{
protocol = "tcp"
port_range = "53"
destination_addresses = ["${var.allowed_outbound_dns_addresses}"]
destination_tags = ["${var.allowed_outbound_dns_tags}"]
destination_droplet_ids = ["${var.allowed_outbound_dns_droplet_ids}"]
destination_load_balancer_uids = ["${var.allowed_outbound_dns_load_balancer_uids}"]
},
]
}
resource "digitalocean_firewall" "outbound-ntp" {
name = "${var.prefix}-ntp-outbound-fw"
droplet_ids = ["${var.droplet_ids}"]
tags = ["${var.tags}"]
# ntp access
outbound_rule = [
{
protocol = "udp"
port_range = "123"
destination_addresses = ["${var.allowed_outbound_ntp_addresses}"]
destination_tags = ["${var.allowed_outbound_ntp_tags}"]
destination_droplet_ids = ["${var.allowed_outbound_ntp_droplet_ids}"]
},
]
}
resource "digitalocean_firewall" "outbound-ssh" {
name = "${var.prefix}-ssh-outbound-fw"
droplet_ids = ["${var.droplet_ids}"]
tags = ["${var.tags}"]
# git/ssh connection
outbound_rule = [
{
protocol = "tcp"
port_range = "22"
destination_addresses = ["${var.allowed_outbound_ssh_addresses}"]
destination_tags = ["${var.allowed_outbound_ssh_tags}"]
destination_droplet_ids = ["${var.allowed_outbound_ssh_droplet_ids}"]
},
]
}
resource "digitalocean_firewall" "inbound-ssh" {
name = "${var.prefix}-ssh-inbound-fw"
droplet_ids = ["${var.droplet_ids}"]
tags = ["${var.tags}"]
inbound_rule = [
{
protocol = "tcp"
port_range = "22"
source_tags = ["${var.allowed_inbound_ssh_tags}"]
source_droplet_ids = ["${var.allowed_inbound_ssh_droplet_ids}"]
source_addresses = ["${var.allowed_inbound_ssh_adresses}"]
},
]
}