-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetwork.tf
96 lines (78 loc) · 2.72 KB
/
Network.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
resource "oci_core_vcn" "lb_demo_vcn" {
cidr_block = "10.0.0.0/16"
compartment_id = oci_identity_compartment.demo.id
dns_label = "lbdemo"
display_name = "LB-Demo-VCN"
}
resource "oci_core_internet_gateway" "lb_demo_igw" {
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
display_name = "LB-DEMO-IGW"
}
resource "oci_core_route_table" "lb_rt" {
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
display_name = "LB_RT"
route_rules {
network_entity_id = oci_core_internet_gateway.lb_demo_igw.id
destination = "0.0.0.0/0"
destination_type = "CIDR_BLOCK"
}
}
resource "oci_core_route_table" "app_rt" {
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
display_name = "APP_RT"
route_rules {
network_entity_id = oci_core_service_gateway.service_gateway.id
//destination = "all-fra-services-in-oracle-services-network"//data.oci_core_services.all_oci_services.services.0.name
destination = lookup(data.oci_core_services.all_oci_services.services[0], "cidr_block")
destination_type = "SERVICE_CIDR_BLOCK"
}
route_rules {
network_entity_id = oci_core_nat_gateway.nat_gateway.id
destination = "0.0.0.0/0"
destination_type = "CIDR_BLOCK"
}
}
resource "oci_core_default_security_list" "lb_demo_default_sl" {
manage_default_resource_id = oci_core_vcn.lb_demo_vcn.default_security_list_id
compartment_id = oci_identity_compartment.demo.id
ingress_security_rules {
protocol = "all"
source = "0.0.0.0/0"
}
egress_security_rules {
protocol = "all"
destination = "0.0.0.0/0"
}
}
resource "oci_core_subnet" "lb_sub" {
cidr_block = "10.0.0.0/24"
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
route_table_id = oci_core_route_table.lb_rt.id
dns_label = "lbsub"
display_name = "LB-Sub"
}
resource "oci_core_subnet" "vm_sub" {
prohibit_public_ip_on_vnic = true
cidr_block = "10.0.1.0/24"
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
route_table_id = oci_core_route_table.app_rt.id
dns_label = "vmsub"
display_name = "VM-Sub"
}
resource "oci_core_service_gateway" "service_gateway" {
compartment_id = oci_identity_compartment.demo.id
display_name = "SGW"
services {
service_id = data.oci_core_services.all_oci_services.services.0.id
}
vcn_id = oci_core_vcn.lb_demo_vcn.id
}
resource "oci_core_nat_gateway" "nat_gateway" {
compartment_id = oci_identity_compartment.demo.id
vcn_id = oci_core_vcn.lb_demo_vcn.id
}