1+ // Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
2+ // Licensed under the Mozilla Public License v2.0
3+
4+ data "oci_identity_availability_domains" "ADsRelocate" {
5+ compartment_id = " ${ var . compartment_id } "
6+ }
7+
8+ resource "oci_core_virtual_network" "relocate" {
9+ compartment_id = " ${ var . compartment_id } "
10+ cidr_block = " 10.1.0.0/16"
11+ display_name = " -tf-vcn-clone"
12+ dns_label = " tfvcnclone"
13+ }
14+
15+ resource "oci_core_route_table" "relocate" {
16+ compartment_id = " ${ var . compartment_id } "
17+ vcn_id = " ${ oci_core_virtual_network . relocate . id } "
18+ route_rules {
19+ cidr_block = " 0.0.0.0/0"
20+ network_entity_id = " ${ oci_core_internet_gateway . relocate . id } "
21+ }
22+ }
23+ resource "oci_core_internet_gateway" "relocate" {
24+ compartment_id = " ${ var . compartment_id } "
25+ vcn_id = " ${ oci_core_virtual_network . relocate . id } "
26+ display_name = " -tf-internet-gateway-clone"
27+ }
28+
29+ resource "oci_core_subnet" "relocate" {
30+ availability_domain = " ${ data . oci_identity_availability_domains . ADsRelocate . availability_domains . 0 . name } "
31+ cidr_block = " 10.1.20.0/24"
32+ display_name = " TFSubnetClone1"
33+ compartment_id = " ${ var . compartment_id } "
34+ vcn_id = " ${ oci_core_virtual_network . relocate . id } "
35+ route_table_id = " ${ oci_core_route_table . relocate . id } "
36+ dhcp_options_id = " ${ oci_core_virtual_network . relocate . default_dhcp_options_id } "
37+ security_list_ids = [" ${ oci_core_virtual_network . relocate . default_security_list_id } " ]
38+ dns_label = " tfsubnetclone"
39+ }
40+ resource "oci_core_subnet" "t2Clone" {
41+ availability_domain = " ${ data . oci_identity_availability_domains . ADsRelocate . availability_domains . 0 . name } "
42+ cidr_block = " 10.1.21.0/24"
43+ display_name = " TFSubnetClone2"
44+ compartment_id = " ${ var . compartment_id } "
45+ vcn_id = " ${ oci_core_virtual_network . relocate . id } "
46+ route_table_id = " ${ oci_core_route_table . relocate . id } "
47+ dhcp_options_id = " ${ oci_core_virtual_network . relocate . default_dhcp_options_id } "
48+ security_list_ids = [" ${ oci_core_virtual_network . relocate . default_security_list_id } " ]
49+ dns_label = " tfsubnetclone2"
50+ }
51+ resource "oci_core_network_security_group" "test_network_security_group_clone" {
52+ compartment_id = " ${ var . compartment_id } "
53+ vcn_id = " ${ oci_core_virtual_network . relocate . id } "
54+ display_name = " displayName"
55+ }
56+
57+ resource "oci_core_network_security_group" "test_network_security_group_clone2" {
58+ compartment_id = " ${ var . compartment_id } "
59+ vcn_id = " ${ oci_core_virtual_network . relocate . id } "
60+ }
61+
62+ resource "oci_database_db_system" "relocate" {
63+ compartment_id = " ${ var . compartment_id } "
64+ subnet_id = " ${ oci_core_subnet . relocate . id } "
65+ database_edition = " ENTERPRISE_EDITION"
66+ availability_domain = " ${ data . oci_identity_availability_domains . ADsRelocate . availability_domains . 0 . name } "
67+ disk_redundancy = " NORMAL"
68+ shape = " VM.Standard2.1"
69+ ssh_public_keys = [" ssh-rsa KKKLK3NzaC1yc2EAAAADAQABAAABAQC+UC9MFNA55NIVtKPIBCNw7++ACXhD0hx+Zyj25JfHykjz/QU3Q5FAU3DxDbVXyubgXfb/GJnrKRY8O4QDdvnZZRvQFFEOaApThAmCAM5MuFUIHdFvlqP+0W+ZQnmtDhwVe2NCfcmOrMuaPEgOKO3DOW6I/qOOdO691Xe2S9NgT9HhN0ZfFtEODVgvYulgXuCCXsJs+NUqcHAOxxFUmwkbPvYi0P0e2DT8JKeiOOC8VKUEgvVx+GKmqasm+Y6zHFW7vv3g2GstE1aRs3mttHRoC/JPM86PRyIxeWXEMzyG5wHqUu4XZpDbnWNxi6ugxnAGiL3CrIFdCgRNgHz5qS1l MustWin" ]
70+ display_name = " -tf-dbSystem-clone-001"
71+ domain = " ${ oci_core_subnet . relocate . dns_label } .${ oci_core_virtual_network . relocate . dns_label } .oraclevcn.com"
72+ hostname = " myOracleDB" // this will be lowercased server side
73+ data_storage_size_in_gb = " 256"
74+ license_model = " LICENSE_INCLUDED"
75+ node_count = " 1"
76+ cpu_core_count = " ${ var . cpu_core_count } "
77+ fault_domains = [" FAULT-DOMAIN-1" ]
78+ db_home {
79+ db_version = " 21.8.0.0"
80+ display_name = " -tf-db-home-clone"
81+ database {
82+ admin_password = " BEstrO0ng_#11"
83+ db_name = " aTFdbC"
84+ character_set = " AL32UTF8"
85+ defined_tags = " ${ map (" example-tag-namespace-all.example-tag" , " originalValue" )} "
86+ freeform_tags = {" Department" = " Finance" }
87+ ncharacter_set = " AL16UTF16"
88+ db_workload = " OLTP"
89+ pdb_name = " pdbName"
90+ }
91+ }
92+ db_system_options {
93+ storage_management = " LVM"
94+ }
95+ defined_tags = " ${ map (" example-tag-namespace-all.example-tag" , " originalValue" )} "
96+ freeform_tags = {" Department" = " Finance" }
97+ nsg_ids = [" ${ oci_core_network_security_group . test_network_security_group_clone . id } " ]
98+ lifecycle {
99+ ignore_changes = [
100+ db_home . 0 . db_version ,
101+ defined_tags ,
102+ db_home . 0 . database . 0 . defined_tags ,
103+ ]
104+ }
105+ }
106+ data "oci_database_db_systems" "relocate" {
107+ compartment_id = " ${ var . compartment_id } "
108+ filter {
109+ name = " id"
110+ values = [" ${ oci_database_db_system . relocate . id } " ]
111+ }
112+ }
113+ data "oci_database_db_homes" "relocate" {
114+ compartment_id = " ${ var . compartment_id } "
115+ db_system_id = " ${ oci_database_db_system . relocate . id } "
116+ filter {
117+ name = " db_system_id"
118+ values = [" ${ oci_database_db_system . relocate . id } " ]
119+ }
120+ }
121+ data "oci_database_db_home" "relocate" {
122+ db_home_id = " ${ data . oci_database_db_homes . relocate . db_homes . 0 . db_home_id } "
123+ }
124+ data "oci_database_databases" "relocate" {
125+ compartment_id = " ${ var . compartment_id } "
126+ db_home_id = " ${ data . oci_database_db_homes . relocate . db_homes . 0 . id } "
127+ filter {
128+ name = " db_name"
129+ values = [" ${ oci_database_db_system . relocate . db_home . 0 . database . 0 . db_name } " ]
130+ }
131+ }
132+ data "oci_database_database" "relocate" {
133+ database_id = " ${ data . oci_database_databases . relocate . databases . 0 . id } "
134+ }
135+
136+ resource "oci_database_pluggable_databases_local_clone" "test_pluggable_databases_relocate" {
137+ pdb_name = " pdbRelocate"
138+ container_database_id = " ${ data . oci_database_database . relocate . id } "
139+ tde_wallet_password = " BEstrO0ng_#11"
140+ pdb_admin_password = " BEstrO0ng_#11"
141+ pdb_creation_type_details {
142+ creation_type = " RELOCATE"
143+ source_pluggable_database_id = " ${ oci_database_pluggable_database . test_pluggable_database2 . id } "
144+ source_container_database_admin_password = " BEstrO0ng_#11"
145+ }
146+ }
0 commit comments