1+ // Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+ // Licensed under the Mozilla Public License v2.0
3+ resource "oci_core_vcn" "vcn" {
4+ cidr_block = " 10.1.0.0/16"
5+ compartment_id = var. compartment_ocid
6+ display_name = " TFExampleVCNDBSystem"
7+ dns_label = " tfexvcndbsys"
8+ }
9+
10+ resource "oci_core_subnet" "subnet" {
11+ availability_domain = data. oci_identity_availability_domain . ad . name
12+ cidr_block = " 10.1.20.0/24"
13+ display_name = " TFExampleSubnetDBSystem"
14+ dns_label = " tfexsubdbsys"
15+ security_list_ids = [oci_core_security_list . ExampleSecurityList . id ]
16+ compartment_id = var. compartment_ocid
17+ vcn_id = oci_core_vcn. vcn . id
18+ route_table_id = oci_core_route_table. route_table . id
19+ dhcp_options_id = oci_core_vcn. vcn . default_dhcp_options_id
20+ }
21+
22+ resource "oci_core_subnet" "subnet_backup" {
23+ availability_domain = data. oci_identity_availability_domain . ad . name
24+ cidr_block = " 10.1.1.0/24"
25+ display_name = " TFExampleSubnetDBSystemBackup"
26+ dns_label = " tfexsubdbsysbp"
27+ security_list_ids = [oci_core_security_list . ExampleSecurityList . id ]
28+ compartment_id = var. compartment_ocid
29+ vcn_id = oci_core_vcn. vcn . id
30+ route_table_id = oci_core_route_table. route_table_backup . id
31+ dhcp_options_id = oci_core_vcn. vcn . default_dhcp_options_id
32+ }
33+
34+ resource "oci_core_internet_gateway" "internet_gateway" {
35+ compartment_id = var. compartment_ocid
36+ display_name = " TFExampleIGDBSystem"
37+ vcn_id = oci_core_vcn. vcn . id
38+ }
39+
40+ resource "oci_core_route_table" "route_table" {
41+ compartment_id = var. compartment_ocid
42+ vcn_id = oci_core_vcn. vcn . id
43+ display_name = " TFExampleRouteTableDBSystem"
44+
45+ route_rules {
46+ destination = " 0.0.0.0/0"
47+ destination_type = " CIDR_BLOCK"
48+ network_entity_id = oci_core_internet_gateway. internet_gateway . id
49+ }
50+ }
51+
52+ resource "oci_core_route_table" "route_table_backup" {
53+ compartment_id = var. compartment_ocid
54+ vcn_id = oci_core_vcn. vcn . id
55+ display_name = " TFExampleRouteTableDBSystemBackup"
56+
57+ route_rules {
58+ destination = " 0.0.0.0/0"
59+ destination_type = " CIDR_BLOCK"
60+ network_entity_id = oci_core_internet_gateway. internet_gateway . id
61+ }
62+ }
63+
64+ resource "oci_core_security_list" "ExampleSecurityList" {
65+ compartment_id = var. compartment_ocid
66+ vcn_id = oci_core_vcn. vcn . id
67+ display_name = " TFExampleSecurityList"
68+
69+ // allow outbound tcp traffic on all ports
70+ egress_security_rules {
71+ destination = " 0.0.0.0/0"
72+ protocol = " 6"
73+ }
74+
75+ // allow outbound udp traffic on a port range
76+ egress_security_rules {
77+ destination = " 0.0.0.0/0"
78+ protocol = " 17" // udp
79+ stateless = true
80+ }
81+
82+ egress_security_rules {
83+ destination = " 0.0.0.0/0"
84+ protocol = " 1"
85+ stateless = true
86+ }
87+
88+ // allow inbound ssh traffic from a specific port
89+ ingress_security_rules {
90+ protocol = " 6" // tcp
91+ source = " 0.0.0.0/0"
92+ stateless = false
93+ }
94+
95+ // allow inbound icmp traffic of a specific type
96+ ingress_security_rules {
97+ protocol = 1
98+ source = " 0.0.0.0/0"
99+ stateless = true
100+ }
101+ }
102+
103+ resource "oci_core_network_security_group" "test_network_security_group" {
104+ compartment_id = var. compartment_ocid
105+ vcn_id = oci_core_vcn. vcn . id
106+ display_name = " displayName"
107+ }
108+
109+ resource "oci_core_network_security_group" "test_network_security_group_backup" {
110+ compartment_id = var. compartment_ocid
111+ vcn_id = oci_core_vcn. vcn . id
112+ display_name = " displayName"
113+ }
0 commit comments