-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnsgs.tf
121 lines (102 loc) · 3.8 KB
/
nsgs.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
## Copyright (c) 2021, 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
resource "oci_core_network_security_group" "WebSecurityGroup" {
compartment_id = var.default_compartment_id
display_name = "WebSecurityGroup"
vcn_id = oci_core_vcn.coa_demo_vcn.id
defined_tags = {
"CCA_Basic_Tag.email" = data.oci_identity_user.coa_demo_executer.name
}
}
resource "oci_core_network_security_group" "SSHSecurityGroup" {
compartment_id = var.default_compartment_id
display_name = "SSHSecurityGroup"
vcn_id = oci_core_vcn.coa_demo_vcn.id
defined_tags = {
"CCA_Basic_Tag.email" = data.oci_identity_user.coa_demo_executer.name
}
}
resource "oci_core_network_security_group" "ATPSecurityGroup" {
compartment_id = var.default_compartment_id
display_name = "ATPSecurityGroup"
vcn_id = oci_core_vcn.coa_demo_vcn.id
defined_tags = {
"CCA_Basic_Tag.email" = data.oci_identity_user.coa_demo_executer.name
}
}
# 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 = var.vcn_cidr
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 = var.vcn_cidr
source_type = "CIDR_BLOCK"
tcp_options {
destination_port_range {
max = 1522
min = 1522
}
}
}
# 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 = "0.0.0.0/0"
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 = "0.0.0.0/0"
source_type = "CIDR_BLOCK"
tcp_options {
destination_port_range {
max = 80
min = 80
}
}
}
# 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
}
}
}