-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetworkSecurityGroups.tf
92 lines (79 loc) · 2.59 KB
/
NetworkSecurityGroups.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
resource "oci_core_network_security_group" "lb_nsg" {
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
display_name = "lb_nsg"
}
resource "oci_core_network_security_group_security_rule" "lb_nsg_ingress" {
network_security_group_id = oci_core_network_security_group.lb_nsg.id
direction = "INGRESS"
protocol = 6
description = "Allow Public Access"
source = "0.0.0.0/0"
source_type = "CIDR_BLOCK"
for_each = toset(["80","443"])
tcp_options {
source_port_range {
max = each.key
min = each.key
}
}
}
resource "oci_core_network_security_group_security_rule" "lb_nsg_egress" {
depends_on = [
oci_core_network_security_group.crtbot_nsg,
oci_core_network_security_group.websrvr_nsg
]
network_security_group_id = oci_core_network_security_group.lb_nsg.id
direction = "EGRESS"
protocol = 6
for_each = {"80" : oci_core_network_security_group.crtbot_nsg.id,
"22" : oci_core_network_security_group.crtbot_nsg.id,
"8080" : oci_core_network_security_group.websrvr_nsg.id}
description = "Access VMs"
destination = each.value
destination_type = "NETWORK_SECURITY_GROUP"
tcp_options {
destination_port_range {
max = each.key
min = each.key
}
}
}
resource "oci_core_network_security_group" "crtbot_nsg" {
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
display_name = "crtbot_nsg"
}
resource "oci_core_network_security_group_security_rule" "crtbot_nsg_ingress" {
network_security_group_id = oci_core_network_security_group.crtbot_nsg.id
direction = "INGRESS"
protocol = 6
description = "ACME Challenge"
source = oci_core_network_security_group.lb_nsg.id
source_type = "NETWORK_SECURITY_GROUP"
tcp_options {
source_port_range {
max = 80
min = 80
}
}
}
resource "oci_core_network_security_group" "websrvr_nsg" {
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
display_name = "websrvr_nsg"
}
resource "oci_core_network_security_group_security_rule" "websrvr_nsg_ingress" {
network_security_group_id = oci_core_network_security_group.websrvr_nsg.id
direction = "INGRESS"
protocol = 6
source = oci_core_network_security_group.lb_nsg.id
source_type = "NETWORK_SECURITY_GROUP"
for_each = toset(["22","8080"])
tcp_options {
source_port_range {
max = each.key
min = each.key
}
}
}