-
Notifications
You must be signed in to change notification settings - Fork 1
/
sgs.tf
140 lines (119 loc) · 6.05 KB
/
sgs.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Provisioner ssh access
resource "aws_security_group_rule" "allow_ssh_from_provisioner_to_cluster" {
count = 3
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
source_security_group_id = "${module.provisioner.sg}"
security_group_id = "${element(list(module.app.sg,module.infra.sg,module.master.sg), count.index)}"
}
//<Enable overlay networking for the cluster
resource "aws_security_group_rule" "allowed_ovs_port_from_cluster_to_master" {
count = 3
type = "ingress"
from_port = "${var.allowed_ovs_port_inside_cluster}"
to_port = "${var.allowed_ovs_port_inside_cluster}"
protocol = "udp"
source_security_group_id = "${element(list(module.app.sg,module.infra.sg,module.master.sg), count.index)}"
security_group_id = "${module.master.sg}"
}
resource "aws_security_group_rule" "allowed_ovs_port_from_cluster_to_app" {
count = 3
type = "ingress"
from_port = "${var.allowed_ovs_port_inside_cluster}"
to_port = "${var.allowed_ovs_port_inside_cluster}"
protocol = "udp"
source_security_group_id = "${element(list(module.app.sg,module.infra.sg,module.master.sg), count.index)}"
security_group_id = "${module.app.sg}"
}
resource "aws_security_group_rule" "allowed_ovs_port_from_cluster_to_infra" {
count = 3
type = "ingress"
from_port = "${var.allowed_ovs_port_inside_cluster}"
to_port = "${var.allowed_ovs_port_inside_cluster}"
protocol = "udp"
source_security_group_id = "${element(list(module.app.sg,module.infra.sg,module.master.sg), count.index)}"
security_group_id = "${module.infra.sg}"
}
//>
//<Allow from master to master
resource "aws_security_group_rule" "allow_ports_tcp_from_master_to_master" {
count = "${length(var.allowed_ports_tcp_from_master_to_master)}"
type = "ingress"
from_port = "${element(var.allowed_ports_tcp_from_master_to_master, count.index)}"
to_port = "${element(var.allowed_ports_tcp_from_master_to_master, count.index)}"
protocol = "tcp"
self = "true"
security_group_id = "${module.master.sg}"
}
resource "aws_security_group_rule" "allow_ports_udp_from_master_to_master" {
count = "${length(var.allowed_ports_udp_from_master_to_master)}"
type = "ingress"
from_port = "${element(var.allowed_ports_udp_from_master_to_master, count.index)}"
to_port = "${element(var.allowed_ports_udp_from_master_to_master, count.index)}"
protocol = "udp"
self = "true"
security_group_id = "${module.master.sg}"
}
//>
//< Allow from all nodes to master
resource "aws_security_group_rule" "allow_ports_tcp_from_app_to_master" {
count = "${length(var.allowed_ports_tcp_from_node_to_master)}"
type = "ingress"
from_port = "${element(var.allowed_ports_tcp_from_node_to_master, count.index)}"
to_port = "${element(var.allowed_ports_tcp_from_node_to_master, count.index)}"
protocol = "tcp"
source_security_group_id = "${module.app.sg}"
security_group_id = "${module.master.sg}"
}
resource "aws_security_group_rule" "allow_ports_udp_from_app_to_master" {
count = "${length(var.allowed_ports_udp_from_node_to_master)}"
type = "ingress"
from_port = "${element(var.allowed_ports_udp_from_node_to_master, count.index)}"
to_port = "${element(var.allowed_ports_udp_from_node_to_master, count.index)}"
protocol = "udp"
source_security_group_id = "${module.app.sg}"
security_group_id = "${module.master.sg}"
}
resource "aws_security_group_rule" "allow_ports_tcp_from_infra_to_master" {
count = "${length(var.allowed_ports_tcp_from_node_to_master)}"
type = "ingress"
from_port = "${element(var.allowed_ports_tcp_from_node_to_master, count.index)}"
to_port = "${element(var.allowed_ports_tcp_from_node_to_master, count.index)}"
protocol = "tcp"
source_security_group_id = "${module.infra.sg}"
security_group_id = "${module.master.sg}"
}
resource "aws_security_group_rule" "allow_ports_udp_from_infra_to_master" {
count = "${length(var.allowed_ports_udp_from_node_to_master)}"
type = "ingress"
from_port = "${element(var.allowed_ports_udp_from_node_to_master, count.index)}"
to_port = "${element(var.allowed_ports_udp_from_node_to_master, count.index)}"
protocol = "udp"
source_security_group_id = "${module.infra.sg}"
security_group_id = "${module.master.sg}"
}
//>
//<
resource "aws_security_group_rule" "allow_ports_tcp_from_master_inside_cluster" {
count = 3
type = "ingress"
from_port = "${element(var.allowed_ports_tcp_from_master_inside_cluster, count.index)}"
to_port = "${element(var.allowed_ports_tcp_from_master_inside_cluster, count.index)}"
protocol = "tcp"
source_security_group_id = "${module.master.sg}"
security_group_id = "${element(list(module.app.sg,module.infra.sg,module.master.sg), count.index)}"
}
//>
//<Public access to infra routers
resource "aws_security_group_rule" "allowed_ports_tcp_from_public_to_infra" {
count = "${length(var.allowed_ports_tcp_from_public_to_infra)}"
type = "ingress"
from_port = "${element(var.allowed_ports_tcp_from_public_to_infra, count.index)}"
to_port = "${element(var.allowed_ports_tcp_from_public_to_infra, count.index)}"
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${module.infra.sg}"
}
//>