forked from oracle-quickstart/oci-arch-web-ha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnsg.tf
147 lines (141 loc) · 5.03 KB
/
nsg.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
## Copyright © 2020, Oracle and/or its affiliates.
## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
# ATPSecurityGroup
resource "oci_core_network_security_group" "ATPSecurityGroup" {
compartment_id = var.compartment_ocid
display_name = "ATPSecurityGroup"
vcn_id = oci_core_virtual_network.vcn.id
defined_tags = {"${oci_identity_tag_namespace.ArchitectureCenterTagNamespace.name}.${oci_identity_tag.ArchitectureCenterTag.name}" = var.release }
lifecycle {
ignore_changes = [ defined_tags["Oracle-Tags.CreatedBy"], defined_tags["Oracle-Tags.CreatedOn"] ]
}
}
# Rules related to ATPSecurityGroup
# EGRESS
resource "oci_core_network_security_group_security_rule" "ATPSecurityEgressGroupRule" {
network_security_group_id = oci_core_network_security_group.ATPSecurityGroup.id
direction = "EGRESS"
protocol = "6"
destination = "10.0.1.0/24"
destination_type = "CIDR_BLOCK"
}
# INGRESS
resource "oci_core_network_security_group_security_rule" "ATPSecurityIngressGroupRules" {
network_security_group_id = oci_core_network_security_group.ATPSecurityGroup.id
direction = "INGRESS"
protocol = "6"
source = "10.0.1.0/24"
source_type = "CIDR_BLOCK"
tcp_options {
destination_port_range {
max = 1522
min = 1522
}
}
}
# WebSecurityGroup
resource "oci_core_network_security_group" "WebSecurityGroup" {
compartment_id = var.compartment_ocid
display_name = "WebSecurityGroup"
vcn_id = oci_core_virtual_network.vcn.id
defined_tags = {"${oci_identity_tag_namespace.ArchitectureCenterTagNamespace.name}.${oci_identity_tag.ArchitectureCenterTag.name}" = var.release }
lifecycle {
ignore_changes = [ defined_tags["Oracle-Tags.CreatedBy"], defined_tags["Oracle-Tags.CreatedOn"] ]
}
}
# Rules related to WebSecurityGroup
# EGRESS
resource "oci_core_network_security_group_security_rule" "WebSecurityEgressATPGroupRule" {
network_security_group_id = oci_core_network_security_group.WebSecurityGroup.id
direction = "EGRESS"
protocol = "6"
destination = oci_core_network_security_group.ATPSecurityGroup.id
destination_type = "NETWORK_SECURITY_GROUP"
}
resource "oci_core_network_security_group_security_rule" "WebSecurityEgressInternetGroupRule" {
network_security_group_id = oci_core_network_security_group.WebSecurityGroup.id
direction = "EGRESS"
protocol = "6"
destination = "10.0.0.0/24"
destination_type = "CIDR_BLOCK"
}
# INGRESS
resource "oci_core_network_security_group_security_rule" "WebSecurityIngressGroupRules" {
network_security_group_id = oci_core_network_security_group.WebSecurityGroup.id
direction = "INGRESS"
protocol = "6"
source = "10.0.0.0/24"
source_type = "CIDR_BLOCK"
tcp_options {
destination_port_range {
max = 5000
min = 5000
}
}
}
# LBSecurityGroup
resource "oci_core_network_security_group" "LBSecurityGroup" {
compartment_id = var.compartment_ocid
display_name = "LBSecurityGroup"
vcn_id = oci_core_virtual_network.vcn.id
defined_tags = {"${oci_identity_tag_namespace.ArchitectureCenterTagNamespace.name}.${oci_identity_tag.ArchitectureCenterTag.name}" = var.release }
lifecycle {
ignore_changes = [ defined_tags["Oracle-Tags.CreatedBy"], defined_tags["Oracle-Tags.CreatedOn"] ]
}
}
# Rules related to LBSecurityGroup
# EGRESS
resource "oci_core_network_security_group_security_rule" "LBSecurityEgressInternetGroupRule" {
network_security_group_id = oci_core_network_security_group.LBSecurityGroup.id
direction = "EGRESS"
protocol = "6"
destination = "0.0.0.0/0"
destination_type = "CIDR_BLOCK"
}
# INGRESS
resource "oci_core_network_security_group_security_rule" "LBSecurityIngressGroupRules" {
network_security_group_id = oci_core_network_security_group.LBSecurityGroup.id
direction = "INGRESS"
protocol = "6"
source = "0.0.0.0/0"
source_type = "CIDR_BLOCK"
tcp_options {
destination_port_range {
max = 80
min = 80
}
}
}
# SSHSecurityGroup
resource "oci_core_network_security_group" "SSHSecurityGroup" {
compartment_id = var.compartment_ocid
display_name = "SSHSecurityGroup"
vcn_id = oci_core_virtual_network.vcn.id
defined_tags = {"${oci_identity_tag_namespace.ArchitectureCenterTagNamespace.name}.${oci_identity_tag.ArchitectureCenterTag.name}" = var.release }
lifecycle {
ignore_changes = [ defined_tags["Oracle-Tags.CreatedBy"], defined_tags["Oracle-Tags.CreatedOn"] ]
}
}
# Rules related to SSHSecurityGroup
# EGRESS
resource "oci_core_network_security_group_security_rule" "SSHSecurityEgressGroupRule" {
network_security_group_id = oci_core_network_security_group.SSHSecurityGroup.id
direction = "EGRESS"
protocol = "6"
destination = "0.0.0.0/0"
destination_type = "CIDR_BLOCK"
}
# INGRESS
resource "oci_core_network_security_group_security_rule" "SSHSecurityIngressGroupRules" {
network_security_group_id = oci_core_network_security_group.SSHSecurityGroup.id
direction = "INGRESS"
protocol = "6"
source = "0.0.0.0/0"
source_type = "CIDR_BLOCK"
tcp_options {
destination_port_range {
max = 22
min = 22
}
}
}