|
| 1 | +// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | +// Licensed under the Mozilla Public License v2.0 |
| 3 | + |
| 4 | +variable "tenancy_ocid" { |
| 5 | +} |
| 6 | + |
| 7 | +variable "user_ocid" { |
| 8 | +} |
| 9 | + |
| 10 | +variable "fingerprint" { |
| 11 | +} |
| 12 | + |
| 13 | +variable "private_key_path" { |
| 14 | +} |
| 15 | + |
| 16 | +variable "region" { |
| 17 | +} |
| 18 | + |
| 19 | +variable "compartment_ocid" { |
| 20 | +} |
| 21 | + |
| 22 | +provider "oci" { |
| 23 | + tenancy_ocid = var.tenancy_ocid |
| 24 | + user_ocid = var.user_ocid |
| 25 | + fingerprint = var.fingerprint |
| 26 | + private_key_path = var.private_key_path |
| 27 | + region = var.region |
| 28 | +} |
| 29 | + |
| 30 | +resource "oci_core_vcn" "test_vcn" { |
| 31 | + cidr_block = "10.0.0.0/16" |
| 32 | + compartment_id = var.compartment_ocid |
| 33 | + display_name = "exampleVCN" |
| 34 | + dns_label = "tfexamplevcn" |
| 35 | +} |
| 36 | + |
| 37 | +resource "oci_core_subnet" "test_subnet" { |
| 38 | + cidr_block = "10.0.1.0/24" |
| 39 | + display_name = "regionalSubnet" |
| 40 | + dns_label = "regionalsubnet" |
| 41 | + compartment_id = var.compartment_ocid |
| 42 | + vcn_id = oci_core_vcn.test_vcn.id |
| 43 | +} |
| 44 | + |
| 45 | +resource "oci_data_safe_data_safe_configuration" "test_data_safe_configuration" { |
| 46 | + is_enabled = "true" |
| 47 | +} |
| 48 | + |
| 49 | +resource "oci_data_safe_data_safe_private_endpoint" "test_data_safe_private_endpoint" { |
| 50 | + compartment_id = var.compartment_ocid |
| 51 | + display_name = "PE2" |
| 52 | + subnet_id = oci_core_subnet.test_subnet.id |
| 53 | + vcn_id = oci_core_vcn.test_vcn.id |
| 54 | +} |
| 55 | + |
| 56 | +variable "target_database_description" { |
| 57 | + default = "description" |
| 58 | +} |
| 59 | + |
| 60 | +variable "target_database_display_name" { |
| 61 | + default = "targetDatabase1" |
| 62 | +} |
| 63 | + |
| 64 | +resource "random_string" "autonomous_database_admin_password" { |
| 65 | + length = 16 |
| 66 | + min_numeric = 1 |
| 67 | + min_lower = 1 |
| 68 | + min_upper = 1 |
| 69 | + min_special = 1 |
| 70 | +} |
| 71 | +variable "autonomous_database_db_workload" { |
| 72 | + default = "OLTP" |
| 73 | +} |
| 74 | + |
| 75 | +variable "autonomous_database_freeform_tags" { |
| 76 | + default = { |
| 77 | + "Department" = "Finance" |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +variable "autonomous_database_license_model" { |
| 82 | + default = "LICENSE_INCLUDED" |
| 83 | +} |
| 84 | + |
| 85 | +resource "oci_database_autonomous_database" "autonomous_database" { |
| 86 | + #Required |
| 87 | + admin_password = random_string.autonomous_database_admin_password.result |
| 88 | + compartment_id = var.compartment_ocid |
| 89 | + cpu_core_count = "1" |
| 90 | + data_storage_size_in_tbs = "1" |
| 91 | + db_name = "adbdb1" |
| 92 | + |
| 93 | + #Optional |
| 94 | + db_workload = var.autonomous_database_db_workload |
| 95 | + display_name = "example_autonomous_database" |
| 96 | + freeform_tags = var.autonomous_database_freeform_tags |
| 97 | + is_auto_scaling_enabled = "true" |
| 98 | + license_model = var.autonomous_database_license_model |
| 99 | + is_preview_version_with_service_terms_accepted = "false" |
| 100 | +} |
| 101 | + |
| 102 | +resource "oci_data_safe_target_database" "test_target_database" { |
| 103 | +#Required |
| 104 | + compartment_id = var.compartment_ocid |
| 105 | + display_name = var.target_database_display_name |
| 106 | + |
| 107 | + database_details { |
| 108 | + database_type = "AUTONOMOUS_DATABASE" |
| 109 | + infrastructure_type = "ORACLE_CLOUD" |
| 110 | + autonomous_database_id = oci_database_autonomous_database.autonomous_database.id |
| 111 | + } |
| 112 | + |
| 113 | + #Optional |
| 114 | + connection_option { |
| 115 | + connection_type = "PRIVATE_ENDPOINT" |
| 116 | + datasafe_private_endpoint_id = oci_data_safe_data_safe_private_endpoint.test_data_safe_private_endpoint.id |
| 117 | + } |
| 118 | + description = var.target_database_description |
| 119 | +} |
| 120 | + |
| 121 | +data "oci_data_safe_target_databases" "test_target_databases" { |
| 122 | + compartment_id = var.compartment_ocid |
| 123 | + display_name = var.target_database_display_name |
| 124 | + target_database_id = oci_data_safe_target_database.test_target_database.id |
| 125 | +} |
0 commit comments