1
+ # Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
2
+ # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3
+ #
4
+
5
+ # Network locals
6
+ locals {
7
+ vcn_cidr_blocks = split (" ," , var. vcn_cidr_blocks )
8
+ network_cidrs = {
9
+ VCN-MAIN-CIDR = local.vcn_cidr_blocks[0 ] # e.g.: "10.75.0.0/16" = 65536 usable IPs
10
+ VCN-NATIVE-POD-NETWORKING-REGIONAL-SUBNET-CIDR = cidrsubnet (local. vcn_cidr_blocks [0 ], 1 , 1 ) # e.g.: "10.20.128.0/17" = 32766 usable IPs (10.20.128.0 - 10.20.255.255)
11
+ SUBNET-5GC-OAM-CIDR = cidrsubnet (local. vcn_cidr_blocks [0 ], 9 , 128 ) # e.g.: "10.75.64.0/25" = 128 usable IPs
12
+ SUBNET-5GC-SIGNALLING-CIDR = cidrsubnet (local. vcn_cidr_blocks [0 ], 9 , 129 ) # e.g.: "10.75.64.128/25" = 128 usable IPs
13
+ SUBNET-5G-RAN-CIDR = cidrsubnet (local. vcn_cidr_blocks [0 ], 11 , 520 ) # e.g.: "10.75.65.0/27" = 32 usable IPs
14
+ SUBNET-LEGAL-INTERCEPT-CIDR = cidrsubnet (local. vcn_cidr_blocks [0 ], 11 , 521 ) # e.g.: "10.75.65.32/27" = 32 usable IPs
15
+ SUBNET-5G-EPC-CIDR = cidrsubnet (local. vcn_cidr_blocks [0 ], 11 , 522 ) # e.g.: "10.75.65.64/27" = 32 usable IPs
16
+ ALL-CIDR = " 0.0.0.0/0"
17
+ }
18
+ }
19
+
20
+ # Extra Security Lists for the 5G NF
21
+ locals {
22
+ extra_security_lists = [
23
+ {
24
+ security_list_name = " 5gc_oam_security_list"
25
+ display_name = " 5GC OAM Security List"
26
+ ingress_security_rules = concat (local. common_5g_security_list_ingress_rules , local. temp_all_vcn_security_list_ingress_rules )
27
+ egress_security_rules = concat (local. common_5g_security_list_egress_rules , local. temp_all_vcn_security_list_egress_rules )
28
+ },
29
+ {
30
+ security_list_name = " 5gc_signalling_security_list"
31
+ display_name = " 5GC Signalling (SBI) Security List"
32
+ ingress_security_rules = concat (local. common_5g_security_list_ingress_rules , local. temp_all_vcn_security_list_ingress_rules )
33
+ egress_security_rules = concat (local. common_5g_security_list_egress_rules , local. temp_all_vcn_security_list_egress_rules )
34
+ },
35
+ {
36
+ security_list_name = " 5g_ran_security_list"
37
+ display_name = " 5G RAN Security List"
38
+ ingress_security_rules = concat (local. common_5g_security_list_ingress_rules , local. temp_all_vcn_security_list_ingress_rules )
39
+ egress_security_rules = concat (local. common_5g_security_list_egress_rules , local. temp_all_vcn_security_list_egress_rules )
40
+ },
41
+ {
42
+ security_list_name = " legal_intercept_security_list"
43
+ display_name = " Legal Intercept Security List"
44
+ ingress_security_rules = concat (local. common_5g_security_list_ingress_rules , local. temp_all_vcn_security_list_ingress_rules )
45
+ egress_security_rules = concat (local. common_5g_security_list_egress_rules , local. temp_all_vcn_security_list_egress_rules )
46
+ },
47
+ {
48
+ security_list_name = " 5g_epc_security_list"
49
+ display_name = " 5G EPC Security List"
50
+ ingress_security_rules = concat (local. common_5g_security_list_ingress_rules , local. temp_all_vcn_security_list_ingress_rules )
51
+ egress_security_rules = concat (local. common_5g_security_list_egress_rules , local. temp_all_vcn_security_list_egress_rules )
52
+ }, {
53
+ security_list_name = " 5g_for_pods_security_list"
54
+ display_name = " 5G subnets x pods Security List"
55
+ ingress_security_rules = [{
56
+ description = " Allow 5GC OAM to pod communication"
57
+ source = lookup (local. network_cidrs , " SUBNET-5GC-OAM-CIDR" )
58
+ source_type = " CIDR_BLOCK"
59
+ protocol = local.security_list_ports.all_protocols
60
+ stateless = false
61
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
62
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
63
+ icmp_options = null
64
+ }, {
65
+ description = " Allow 5GC Signalling (SBI) to pod communication"
66
+ source = lookup (local. network_cidrs , " SUBNET-5GC-SIGNALLING-CIDR" )
67
+ source_type = " CIDR_BLOCK"
68
+ protocol = local.security_list_ports.all_protocols
69
+ stateless = false
70
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
71
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
72
+ icmp_options = null
73
+ }, {
74
+ description = " Allow 5G RAN to pod communication"
75
+ source = lookup (local. network_cidrs , " SUBNET-5G-RAN-CIDR " )
76
+ source_type = " CIDR_BLOCK"
77
+ protocol = local.security_list_ports.all_protocols
78
+ stateless = false
79
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
80
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
81
+ icmp_options = null
82
+ }, {
83
+ description = " Allow 5G Legal Intercept to pod communication"
84
+ source = lookup (local. network_cidrs , " SUBNET-LEGAL-INTERCEPT-CIDR" )
85
+ source_type = " CIDR_BLOCK"
86
+ protocol = local.security_list_ports.all_protocols
87
+ stateless = false
88
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
89
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
90
+ icmp_options = null
91
+ }, {
92
+ description = " Allow 5G EPC to pod communication"
93
+ source = lookup (local. network_cidrs , " SUBNET-5G-EPC-CIDR " )
94
+ source_type = " CIDR_BLOCK"
95
+ protocol = local.security_list_ports.all_protocols
96
+ stateless = false
97
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
98
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
99
+ icmp_options = null
100
+ }]
101
+ egress_security_rules = []
102
+ },
103
+ ]
104
+ common_5g_security_list_ingress_rules = [{
105
+ description = " Allow pods to communicate with 5G subnets"
106
+ source = lookup (local. network_cidrs , " VCN-NATIVE-POD-NETWORKING-REGIONAL-SUBNET-CIDR" )
107
+ source_type = " CIDR_BLOCK"
108
+ protocol = local.security_list_ports.all_protocols
109
+ stateless = false
110
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
111
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
112
+ icmp_options = null
113
+ }, {
114
+ description = " Path discovery"
115
+ source = lookup (local. network_cidrs , " ALL-CIDR" )
116
+ source_type = " CIDR_BLOCK"
117
+ protocol = local.security_list_ports.icmp_protocol_number
118
+ stateless = false
119
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
120
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
121
+ icmp_options = { type = " 3" , code = " 4" }
122
+ }]
123
+ common_5g_security_list_egress_rules = [{
124
+ description = " Allow 5G subnets to communicate with pods"
125
+ destination = lookup (local. network_cidrs , " VCN-NATIVE-POD-NETWORKING-REGIONAL-SUBNET-CIDR" )
126
+ destination_type = " CIDR_BLOCK"
127
+ protocol = local.security_list_ports.all_protocols
128
+ stateless = false
129
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
130
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
131
+ icmp_options = null
132
+ }, {
133
+ description = " Path discovery"
134
+ destination = lookup (local. network_cidrs , " ALL-CIDR" )
135
+ destination_type = " CIDR_BLOCK"
136
+ protocol = local.security_list_ports.icmp_protocol_number
137
+ stateless = false
138
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
139
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
140
+ icmp_options = { type = " 3" , code = " 4" }
141
+ }]
142
+ temp_all_vcn_security_list_ingress_rules = [{
143
+ description = " Allow all from VCN"
144
+ source = lookup (local. network_cidrs , " ALL-CIDR" )
145
+ source_type = " CIDR_BLOCK"
146
+ protocol = local.security_list_ports.all_protocols
147
+ stateless = false
148
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
149
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
150
+ icmp_options = null
151
+ }]
152
+ temp_all_vcn_security_list_egress_rules = [{
153
+ description = " Allow all to VCN"
154
+ destination = lookup (local. network_cidrs , " ALL-CIDR" )
155
+ destination_type = " CIDR_BLOCK"
156
+ protocol = local.security_list_ports.all_protocols
157
+ stateless = false
158
+ tcp_options = { max = - 1 , min = - 1 , source_port_range = null }
159
+ udp_options = { max = - 1 , min = - 1 , source_port_range = null }
160
+ icmp_options = null
161
+ }]
162
+ security_list_ports = {
163
+ http_port_number = 80
164
+ https_port_number = 443
165
+ k8s_api_endpoint_port_number = 6443
166
+ k8s_api_endpoint_to_worker_port_number = 10250
167
+ k8s_worker_to_control_plane_port_number = 12250
168
+ ssh_port_number = 22
169
+ tcp_protocol_number = " 6"
170
+ udp_protocol_number = " 17"
171
+ icmp_protocol_number = " 1"
172
+ all_protocols = " all"
173
+ }
174
+ }
175
+
176
+ # Extra Subnets for for the 5G NF
177
+ locals {
178
+ extra_subnets = [
179
+ {
180
+ subnet_name = " 5GC_OAM_subnet"
181
+ cidr_block = lookup (local. network_cidrs , " SUBNET-5GC-OAM-CIDR" )
182
+ display_name = " 5GC OAM subnet"
183
+ dns_label = " sn5gcoam"
184
+ prohibit_public_ip_on_vnic = true
185
+ prohibit_internet_ingress = true
186
+ route_table_id = null
187
+ alternative_route_table_name = " private"
188
+ dhcp_options_id = " "
189
+ security_list_ids = []
190
+ extra_security_list_names = [" 5gc_oam_security_list" ]
191
+ ipv6cidr_block = null
192
+ },
193
+ {
194
+ subnet_name = " 5GC_Signalling_subnet"
195
+ cidr_block = lookup (local. network_cidrs , " SUBNET-5GC-SIGNALLING-CIDR" )
196
+ display_name = " 5GC Signalling (SBI) subnet"
197
+ dns_label = " sn5gcsig"
198
+ prohibit_public_ip_on_vnic = true
199
+ prohibit_internet_ingress = true
200
+ route_table_id = null
201
+ alternative_route_table_name = " private"
202
+ dhcp_options_id = " "
203
+ security_list_ids = []
204
+ extra_security_list_names = [" 5gc_signalling_security_list" ]
205
+ ipv6cidr_block = null
206
+ },
207
+ {
208
+ subnet_name = " 5G_RAN_subnet"
209
+ cidr_block = lookup (local. network_cidrs , " SUBNET-5G-RAN-CIDR" )
210
+ display_name = " 5G RAN subnet"
211
+ dns_label = " sn5gran"
212
+ prohibit_public_ip_on_vnic = true
213
+ prohibit_internet_ingress = true
214
+ route_table_id = null
215
+ alternative_route_table_name = " private"
216
+ dhcp_options_id = " "
217
+ security_list_ids = []
218
+ extra_security_list_names = [" 5g_ran_security_list" ]
219
+ ipv6cidr_block = null
220
+ },
221
+ {
222
+ subnet_name = " Legal_Intercept_subnet"
223
+ cidr_block = lookup (local. network_cidrs , " SUBNET-LEGAL-INTERCEPT-CIDR" )
224
+ display_name = " Legal Intercept subnet"
225
+ dns_label = " snlegalin"
226
+ prohibit_public_ip_on_vnic = true
227
+ prohibit_internet_ingress = true
228
+ route_table_id = null
229
+ alternative_route_table_name = " private"
230
+ dhcp_options_id = " "
231
+ security_list_ids = []
232
+ extra_security_list_names = [" legal_intercept_security_list" ]
233
+ ipv6cidr_block = null
234
+ },
235
+ {
236
+ subnet_name = " 5G_EPC_subnet"
237
+ cidr_block = lookup (local. network_cidrs , " SUBNET-5G-EPC-CIDR" )
238
+ display_name = " 5G EPC subnet"
239
+ dns_label = " sn5gcepc"
240
+ prohibit_public_ip_on_vnic = true
241
+ prohibit_internet_ingress = true
242
+ route_table_id = null
243
+ alternative_route_table_name = " private"
244
+ dhcp_options_id = " "
245
+ security_list_ids = []
246
+ extra_security_list_names = [" 5g_epc_security_list" ]
247
+ ipv6cidr_block = null
248
+ },
249
+ ]
250
+ }
0 commit comments