-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsecurity_groups.tf
More file actions
279 lines (253 loc) · 9.77 KB
/
security_groups.tf
File metadata and controls
279 lines (253 loc) · 9.77 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*
* The following defines a Security Group for FSx ONTAP that allows the required ports for NFS, CIFS,
* Kerberos, and iSCSI as well as SnapMirror.
*
* While you don't have to use this SG, one will need to be assigned to the FSx ONTAP file system,
* otherwise it won't be able to communicate with the clients.
*
* To not create the security group, set the variable create_sg to false in the variables.tf file.
* Will will also need to set the security_group_id to the ID of the security group you want to use
* in the variables.tf file.
*
*/
locals {
mycount = var.dr_create_sg ? 1 : 0
my_ref_sec_group_id = (var.dr_source_sg_id != "" ? var.dr_source_sg_id : null)
my_cidr = (var.dr_cidr_for_sg != "" ? var.dr_cidr_for_sg : null)
}
resource "aws_security_group" "fsx_sg" {
description = "Allow FSx ONTAP required ports"
count = local.mycount
name_prefix = var.dr_security_group_name_prefix
vpc_id = var.dr_vpc_id
}
# locals {
# my_security_group_id = aws_security_group.fsx_sg[count.index].id
# }
resource "aws_vpc_security_group_ingress_rule" "all_icmp" {
description = "Allow all ICMP traffic"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = -1
to_port = -1
ip_protocol = "icmp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_tcp" {
description = "Remote procedure call for NFS"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 111
to_port = 111
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_udp" {
description = "Remote procedure call for NFS"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 111
to_port = 111
ip_protocol = "udp"
}
resource "aws_vpc_security_group_ingress_rule" "cifs" {
description = "NetBIOS service session for CIFS"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 139
to_port = 139
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "snmp_tcp" {
description = "Simple network management protocol for log collection"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 161
to_port = 162
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "snmp_udp" {
description = "Simple network management protocol for log collection"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 161
to_port = 162
ip_protocol = "udp"
}
resource "aws_vpc_security_group_ingress_rule" "smb_cifs" {
description = "Microsoft SMB/CIFS over TCP with NetBIOS framing"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 445
to_port = 445
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_mount_tcp" {
description = "NFS mount"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 635
to_port = 635
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "kerberos" {
description = "Kerberos authentication"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 749
to_port = 749
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_server_daemon" {
description = "NFS server daemon"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 2049
to_port = 2049
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_server_daemon_udp" {
description = "NFS server daemon"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 2049
to_port = 2049
ip_protocol = "udp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_lock_daemon" {
description = "NFS lock daemon"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 4045
to_port = 4045
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_lock_daemon_udp" {
description = "NFS lock daemon"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 4045
to_port = 4045
ip_protocol = "udp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_status_monitor" {
description = "Status monitor for NFS"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 4046
to_port = 4046
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_status_monitor_udp" {
description = "Status monitor for NFS"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 4046
to_port = 4046
ip_protocol = "udp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_rquotad" {
description = "Remote quota server for NFS"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 4049
to_port = 4049
ip_protocol = "udp"
}
resource "aws_vpc_security_group_ingress_rule" "iscsi_tcp" {
description = "iSCSI"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 3260
to_port = 3260
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "Snapmirror_Intercluster_communication" {
description = "Snapmirror Intercluster communication"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 11104
to_port = 11104
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "Snapmirror_data_transfer" {
description = "Snapmirror data transfer"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 11105
to_port = 11105
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "nfs_mount_udp" {
description = "NFS mount"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 635
to_port = 635
ip_protocol = "udp"
}
resource "aws_vpc_security_group_ingress_rule" "ssh" {
description = "ssh"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 22
to_port = 22
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_ingress_rule" "s3_and_api" {
description = "Provice acccess to S3 and the ONTAP REST API"
count = local.mycount
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = local.my_cidr
referenced_security_group_id = local.my_ref_sec_group_id
from_port = 443
to_port = 443
ip_protocol = "tcp"
}
resource "aws_vpc_security_group_egress_rule" "allow_all_traffic" {
count = local.mycount
description = "Allow all out bound traffic"
security_group_id = aws_security_group.fsx_sg[count.index].id
cidr_ipv4 = "0.0.0.0/0"
ip_protocol = "-1"
}