-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsecurity-lists.tf
executable file
·112 lines (92 loc) · 3.05 KB
/
security-lists.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
# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
resource "oci_core_security_list" "dotnet_security_list" {
compartment_id = var.compartment_ocid
vcn_id = oci_core_virtual_network.dotnet_main_vcn.id
display_name = "dotnet-main-${random_string.deploy_id.result}"
freeform_tags = local.common_tags
ingress_security_rules {
protocol = local.all_protocols
source = lookup(var.network_cidrs, "MAIN-SUBNET-REGIONAL-CIDR")
stateless = true
}
ingress_security_rules {
protocol = local.tcp_protocol_number
source = lookup(var.network_cidrs, "MAIN-LB-SUBNET-REGIONAL-CIDR")
tcp_options {
max = local.app_port_number
min = local.app_port_number
}
}
ingress_security_rules {
protocol = local.tcp_protocol_number
source = lookup(var.network_cidrs, (var.instance_visibility == "Private") ? "MAIN-VCN-CIDR" : "ALL-CIDR")
tcp_options {
max = local.ssh_port_number
min = local.ssh_port_number
}
}
egress_security_rules {
protocol = local.all_protocols
destination = lookup(var.network_cidrs, "MAIN-SUBNET-REGIONAL-CIDR")
stateless = true
}
egress_security_rules {
protocol = local.all_protocols
destination = lookup(var.network_cidrs, (var.instance_visibility == "Private") ? "MAIN-VCN-CIDR" : "ALL-CIDR")
}
egress_security_rules {
protocol = local.all_protocols
destination = lookup(data.oci_core_services.all_services.services[0], "cidr_block")
destination_type = "SERVICE_CIDR_BLOCK"
}
}
resource "oci_core_security_list" "dotnet_lb_security_list" {
compartment_id = var.compartment_ocid
vcn_id = oci_core_virtual_network.dotnet_main_vcn.id
display_name = "dotnet-lb-${random_string.deploy_id.result}"
freeform_tags = local.common_tags
ingress_security_rules {
protocol = local.all_protocols
source = lookup(var.network_cidrs, "ALL-CIDR")
stateless = true
}
ingress_security_rules {
protocol = local.tcp_protocol_number
source = lookup(var.network_cidrs, "ALL-CIDR")
tcp_options {
max = local.http_port_number
min = local.http_port_number
}
}
ingress_security_rules {
protocol = local.tcp_protocol_number
source = lookup(var.network_cidrs, "ALL-CIDR")
tcp_options {
max = local.https_port_number
min = local.https_port_number
}
}
egress_security_rules {
protocol = local.all_protocols
destination = lookup(var.network_cidrs, "ALL-CIDR")
stateless = true
}
egress_security_rules {
protocol = local.tcp_protocol_number
destination = lookup(var.network_cidrs, "MAIN-SUBNET-REGIONAL-CIDR")
tcp_options {
max = local.app_port_number
min = local.app_port_number
}
}
}
locals {
http_port_number = "80"
https_port_number = "443"
app_port_number = "5000"
ssh_port_number = "22"
tcp_protocol_number = "6"
all_protocols = "all"
}