-
Notifications
You must be signed in to change notification settings - Fork 7
/
security.tf
167 lines (161 loc) · 4.35 KB
/
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
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
# Copyright 2022 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0
locals {
firewall_controller_allow_source_ranges = (var.firewall_controller_allow_source_range != null ? [var.firewall_controller_allow_source_range] : var.firewall_controller_allow_source_ranges)
}
resource "aws_security_group" "avi_controller_sg" {
count = var.create_firewall_rules ? 1 : 0
name = "${var.name_prefix}-avi-controller-sg"
description = "Allow Traffic for AVI Controller"
vpc_id = var.create_networking ? aws_vpc.avi[0].id : var.custom_vpc_id
ingress {
description = "SSH Ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = local.firewall_controller_allow_source_ranges
}
ingress {
description = "HTTPS from Internet"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = local.firewall_controller_allow_source_ranges
}
ingress {
description = "Secure Channel from VPC"
from_port = 8443
to_port = 8443
protocol = "tcp"
cidr_blocks = [var.avi_cidr_block]
}
ingress {
description = "AVI_CLI from Internet"
from_port = 5054
to_port = 5054
protocol = "tcp"
cidr_blocks = local.firewall_controller_allow_source_ranges
}
ingress {
description = "ICMP to Controller"
from_port = -1
to_port = -1
protocol = "icmp"
cidr_blocks = [var.avi_cidr_block]
}
egress {
description = "Allow traffic from VPC"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "${var.name_prefix}-avi-controller-sg"
}
}
resource "aws_security_group" "avi_se_mgmt_sg" {
count = var.create_firewall_rules ? 1 : 0
name = "${var.name_prefix}-avi-se-mgmt-sg"
description = "Allow traffic for AVI SE MGMT NICs"
vpc_id = var.create_networking ? aws_vpc.avi[0].id : var.custom_vpc_id
ingress {
description = "SSH to SE"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = [var.avi_cidr_block]
}
ingress {
description = "Allow SE distributed object store traffic"
from_port = 4001
to_port = 4001
protocol = "tcp"
cidr_blocks = [var.avi_cidr_block]
}
ingress {
description = "ICMP to SE"
from_port = -1
to_port = -1
protocol = "icmp"
cidr_blocks = [var.avi_cidr_block]
}
ingress {
description = "ETHERIP to SE"
from_port = 0
to_port = 0
protocol = "97"
cidr_blocks = [var.avi_cidr_block]
}
ingress {
description = "CPHB to SE"
from_port = 0
to_port = 0
protocol = "73"
cidr_blocks = [var.avi_cidr_block]
}
ingress {
description = "Proto63 to SE"
from_port = 0
to_port = 0
protocol = "63"
cidr_blocks = [var.avi_cidr_block]
}
egress {
description = "Allow SSH to Controller"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = [var.avi_cidr_block]
}
egress {
description = "Allow SE distributed object store traffic"
from_port = 4001
to_port = 4001
protocol = "tcp"
cidr_blocks = [var.avi_cidr_block]
}
egress {
description = "Allow 8443 to Controller"
from_port = 8443
to_port = 8443
protocol = "tcp"
cidr_blocks = [var.avi_cidr_block]
}
egress {
description = "Allow NTP to Controller"
from_port = 123
to_port = 123
protocol = "udp"
cidr_blocks = [var.avi_cidr_block]
}
tags = {
Name = "${var.name_prefix}-avi-se-mgmt-sg"
}
}
resource "aws_security_group" "avi_data_sg" {
count = var.create_firewall_rules ? 1 : 0
name = "${var.name_prefix}-avi-data-sg"
description = "Allow traffic for Avi SE Data NICs"
vpc_id = var.create_networking ? aws_vpc.avi[0].id : var.custom_vpc_id
dynamic "ingress" {
for_each = var.firewall_se_data_rules
content {
description = ingress.value["description"]
from_port = ingress.value["port"]
to_port = ingress.value["port"]
protocol = ingress.value["protocol"]
cidr_blocks = [ingress.value["allow_ip_range"]]
}
}
egress {
description = "Allow Traffic Outbound"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "${var.name_prefix}-avi-data-sg"
}
}