generated from oracle-quickstart/oci-quickstart-template
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnsg.tf
69 lines (60 loc) · 2.58 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
# ------ Create Network Security Group for Hub VCN
resource "oci_core_network_security_group" "nsg" {
compartment_id = var.network_compartment_ocid
vcn_id = local.use_existing_network ? var.vcn_id : oci_core_vcn.hub.0.id
display_name = var.nsg_display_name
}
# ------ Add Engress Rule to Network Security Group
resource "oci_core_network_security_group_security_rule" "rule_egress_all" {
network_security_group_id = oci_core_network_security_group.nsg.id
direction = "EGRESS"
protocol = "all"
destination = "0.0.0.0/0"
}
# ------ Add Ingress Rule to Network Security Group
resource "oci_core_network_security_group_security_rule" "rule_ingress_all" {
network_security_group_id = oci_core_network_security_group.nsg.id
direction = "INGRESS"
protocol = "all"
source = "0.0.0.0/0"
}
# ------ Create Network Security Group for Web VCN
resource "oci_core_network_security_group" "nsg_web" {
compartment_id = var.network_compartment_ocid
vcn_id = local.use_existing_network ? var.vcn_id : oci_core_vcn.web.0.id
display_name = var.web_nsg_display_name
}
# ------ Add Engress Rule to Network Security Group
resource "oci_core_network_security_group_security_rule" "web_rule_egress_all" {
network_security_group_id = oci_core_network_security_group.nsg_web.id
direction = "EGRESS"
protocol = "all"
destination = "0.0.0.0/0"
}
# ------ Add Ingress Rule to Network Security Group
resource "oci_core_network_security_group_security_rule" "web_rule_ingress_all" {
network_security_group_id = oci_core_network_security_group.nsg_web.id
direction = "INGRESS"
protocol = "all"
source = "0.0.0.0/0"
}
# ------ Create Network Security Group for DB VCN
resource "oci_core_network_security_group" "nsg_db" {
compartment_id = var.network_compartment_ocid
vcn_id = local.use_existing_network ? var.vcn_id : oci_core_vcn.db.0.id
display_name = var.db_nsg_display_name
}
# ------ Add Egress Rule to Network Security Group
resource "oci_core_network_security_group_security_rule" "db_rule_egress_all" {
network_security_group_id = oci_core_network_security_group.nsg_db.id
direction = "EGRESS"
protocol = "all"
destination = "0.0.0.0/0"
}
# ------ Add Ingress Rule to Network Security Group
resource "oci_core_network_security_group_security_rule" "db_rule_ingress_all" {
network_security_group_id = oci_core_network_security_group.nsg_db.id
direction = "INGRESS"
protocol = "all"
source = "0.0.0.0/0"
}