|
| 1 | +// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | +// Licensed under the Mozilla Public License v2.0 |
| 3 | + |
| 4 | +resource "oci_core_vcn" "vcn1" { |
| 5 | + cidr_block = "10.0.0.0/16" |
| 6 | + compartment_id = var.compartment_ocid |
| 7 | + display_name = "TFExampleVCN" |
| 8 | + dns_label = "tfexamplevcn" |
| 9 | +} |
| 10 | + |
| 11 | +resource "oci_core_security_list" "test_security_list" { |
| 12 | + compartment_id = var.compartment_ocid |
| 13 | + vcn_id = oci_core_vcn.vcn1.id |
| 14 | + display_name = "TFExampleSecurityList" |
| 15 | + |
| 16 | + // allow outbound tcp traffic on all ports |
| 17 | + egress_security_rules { |
| 18 | + destination = "0.0.0.0/0" |
| 19 | + protocol = "6" |
| 20 | + } |
| 21 | + |
| 22 | + ingress_security_rules { |
| 23 | + protocol = "6" |
| 24 | + source = "0.0.0.0/0" |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +// An AD based subnet will supply an Availability Domain |
| 29 | +resource "oci_core_subnet" "test_subnet" { |
| 30 | + availability_domain = data.oci_identity_availability_domain.ad.name |
| 31 | + cidr_block = "10.0.2.0/24" |
| 32 | + display_name = "TFADSubnet" |
| 33 | + dns_label = "adsubnet" |
| 34 | + compartment_id = var.compartment_ocid |
| 35 | + vcn_id = oci_core_vcn.vcn1.id |
| 36 | + security_list_ids = [oci_core_security_list.test_security_list.id] |
| 37 | + route_table_id = oci_core_vcn.vcn1.default_route_table_id |
| 38 | + dhcp_options_id = oci_core_vcn.vcn1.default_dhcp_options_id |
| 39 | +} |
| 40 | + |
| 41 | +resource "oci_database_db_system" "test_db_system" { |
| 42 | + availability_domain = oci_core_subnet.test_subnet.availability_domain |
| 43 | + compartment_id = var.compartment_ocid |
| 44 | + subnet_id = oci_core_subnet.test_subnet.id |
| 45 | + database_edition = "ENTERPRISE_EDITION" |
| 46 | + disk_redundancy = "NORMAL" |
| 47 | + shape = "VM.Standard2.1" |
| 48 | + ssh_public_keys = [var.ssh_public_key] |
| 49 | + domain = oci_core_subnet.test_subnet.subnet_domain_name |
| 50 | + hostname = "myOracleDB" |
| 51 | + data_storage_size_in_gb = "256" |
| 52 | + license_model = "LICENSE_INCLUDED" |
| 53 | + node_count = "1" |
| 54 | + display_name = "TFExampleDbSystem" |
| 55 | + |
| 56 | + db_home { |
| 57 | + db_version = "12.1.0.2" |
| 58 | + display_name = "TFExampleDbHome" |
| 59 | + |
| 60 | + database { |
| 61 | + admin_password = "BEstrO0ng_#11" |
| 62 | + db_name = "db1" |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +data "oci_database_db_homes" "t" { |
| 68 | + compartment_id = var.compartment_ocid |
| 69 | + db_system_id = oci_database_db_system.test_db_system.id |
| 70 | + |
| 71 | + filter { |
| 72 | + name = "display_name" |
| 73 | + values = ["TFExampleDbHome"] |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +data "oci_database_databases" "db" { |
| 78 | + compartment_id = var.compartment_ocid |
| 79 | + db_home_id = data.oci_database_db_homes.t.db_homes[0].db_home_id |
| 80 | +} |
| 81 | + |
| 82 | +resource "oci_database_data_guard_association" "test_data_guard_association" { |
| 83 | + #Required |
| 84 | + create_async = true |
| 85 | + creation_type = "NewDbSystem" |
| 86 | + database_admin_password = "BEstrO0ng_#11" |
| 87 | + database_id = data.oci_database_databases.db.databases[0].id |
| 88 | + protection_mode = "MAXIMUM_PERFORMANCE" |
| 89 | + transport_type = "ASYNC" |
| 90 | + delete_standby_db_home_on_delete = "true" |
| 91 | + |
| 92 | + #required for NewDbSystem creation_type |
| 93 | + display_name = "TFExampleDataGuardAssociationVM" |
| 94 | + shape = "VM.Standard2.1" |
| 95 | + subnet_id = oci_core_subnet.test_subnet.id |
| 96 | + availability_domain = oci_core_subnet.test_subnet.availability_domain |
| 97 | + nsg_ids = [oci_core_network_security_group.test_network_security_group_dataguard.id] |
| 98 | + hostname = "ocidb" |
| 99 | +} |
| 100 | + |
| 101 | +resource "oci_core_network_security_group" "test_network_security_group_dataguard" { |
| 102 | + compartment_id = var.compartment_ocid |
| 103 | + vcn_id = oci_core_vcn.vcn1.id |
| 104 | + display_name = "tf-example-nsg" |
| 105 | +} |
| 106 | + |
0 commit comments