-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscw_security.tf
111 lines (102 loc) · 2.47 KB
/
scw_security.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
102
103
104
105
106
107
108
109
110
111
resource "scaleway_instance_security_group" "sg-mail" {
name = "sg-mail"
external_rules = true
inbound_default_policy = "drop"
outbound_default_policy = "accept"
stateful = true
enable_default_security = false
}
resource "scaleway_instance_security_group_rules" "sg-mail-rules" {
security_group_id = scaleway_instance_security_group.sg-mail.id
inbound_rule {
action = "accept"
protocol = "ICMP"
}
inbound_rule {
action = "accept"
protocol = "ANY"
ip = scaleway_instance_server.mail.private_ip
}
dynamic "inbound_rule" {
for_each = var.general_mail_ports
content {
action = "accept"
port = inbound_rule.value
}
}
dynamic "inbound_rule" {
for_each = var.general_mail_ports_udp
content {
action = "accept"
protocol = "UDP"
port = inbound_rule.value
}
}
dynamic "inbound_rule" {
for_each = var.private_mail_ports
content {
action = "accept"
port = inbound_rule.value
ip = var.friendly_ip
}
}
dynamic "inbound_rule" {
for_each = var.private_mail_ports
content {
action = "accept"
port = inbound_rule.value
ip = scaleway_instance_server.core.private_ip
}
}
}
resource "scaleway_instance_security_group" "sg-core" {
name = "sg-core"
external_rules = true
inbound_default_policy = "drop"
outbound_default_policy = "accept"
stateful = true
enable_default_security = false
}
resource "scaleway_instance_security_group_rules" "sg-core_rules" {
security_group_id = scaleway_instance_security_group.sg-core.id
inbound_rule {
action = "accept"
protocol = "ICMP"
}
inbound_rule {
action = "accept"
protocol = "ANY"
ip = scaleway_instance_server.core.private_ip
}
dynamic "inbound_rule" {
for_each = var.general_core_ports
content {
action = "accept"
port = inbound_rule.value
}
}
dynamic "inbound_rule" {
for_each = var.general_core_ports_udp
content {
action = "accept"
protocol = "UDP"
port = inbound_rule.value
}
}
dynamic "inbound_rule" {
for_each = var.private_core_ports
content {
action = "accept"
port = inbound_rule.value
ip = var.friendly_ip
}
}
dynamic "inbound_rule" {
for_each = var.private_core_ports
content {
action = "accept"
port = inbound_rule.value
ip = scaleway_instance_server.mail.private_ip
}
}
}