|
| 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 | +variable "user_ocid" {} |
| 6 | +variable "fingerprint" {} |
| 7 | +variable "private_key_path" {} |
| 8 | +variable "region" {} |
| 9 | +variable "compartment_ocid" {} |
| 10 | +variable "opsi_private_endpoint_id" {} |
| 11 | +variable "dbsystem_database_id" {} |
| 12 | +variable "service_name" {} |
| 13 | +variable "user_name" {} |
| 14 | +variable "secret_id" {} |
| 15 | + |
| 16 | + |
| 17 | +provider "oci" { |
| 18 | + tenancy_ocid = var.tenancy_ocid |
| 19 | + user_ocid = var.user_ocid |
| 20 | + fingerprint = var.fingerprint |
| 21 | + private_key_path = var.private_key_path |
| 22 | + region = var.region |
| 23 | +} |
| 24 | + |
| 25 | +resource "oci_identity_tag_namespace" "tag-namespace1" { |
| 26 | + compartment_id = var.tenancy_ocid |
| 27 | + description = "example tag namespace" |
| 28 | + name = "examples-tag-namespace-all" |
| 29 | + is_retired = false |
| 30 | +} |
| 31 | + |
| 32 | +resource "oci_identity_tag" "tag1" { |
| 33 | + description = "example tag" |
| 34 | + name = "example-tag" |
| 35 | + tag_namespace_id = oci_identity_tag_namespace.tag-namespace1.id |
| 36 | + is_cost_tracking = false |
| 37 | + is_retired = false |
| 38 | +} |
| 39 | + |
| 40 | +variable "database_insight_database_type" { |
| 41 | + default = ["COMANAGED-VM-CDB"] |
| 42 | +} |
| 43 | + |
| 44 | +variable "deployment_type" { |
| 45 | + default = "VIRTUAL_MACHINE" |
| 46 | +} |
| 47 | + |
| 48 | +variable "database_insight_credential_details_credential_type" { |
| 49 | + default = "CREDENTIALS_BY_VAULT" |
| 50 | +} |
| 51 | + |
| 52 | +variable "database_insight_credential_details_role" { |
| 53 | + default = "NORMAL" |
| 54 | +} |
| 55 | + |
| 56 | +variable "database_insight_database_resource_type" { |
| 57 | + default = "database" |
| 58 | +} |
| 59 | + |
| 60 | +variable "database_insight_defined_tags_value" { |
| 61 | + default = "value" |
| 62 | +} |
| 63 | + |
| 64 | +variable "database_insight_entity_source" { |
| 65 | + default = "PE_COMANAGED_DATABASE" |
| 66 | +} |
| 67 | + |
| 68 | +variable "database_insight_fields" { |
| 69 | + default = ["databaseName", "databaseType", "compartmentId", "databaseDisplayName", "freeformTags", "definedTags"] |
| 70 | +} |
| 71 | + |
| 72 | +variable "database_insight_freeform_tags" { |
| 73 | + default = { "bar-key" = "value" } |
| 74 | +} |
| 75 | + |
| 76 | +variable "resource_status" { |
| 77 | + default = "ENABLED" |
| 78 | +} |
| 79 | + |
| 80 | +// Create Database insight for EM managed External Database |
| 81 | +resource "oci_opsi_database_insight" "test_database_insight" { |
| 82 | + #Required |
| 83 | + compartment_id = var.compartment_ocid |
| 84 | + entity_source = var.database_insight_entity_source |
| 85 | + |
| 86 | + #Optional |
| 87 | + opsi_private_endpoint_id = var.opsi_private_endpoint_id |
| 88 | + service_name = var.service_name |
| 89 | + database_id = var.dbsystem_database_id |
| 90 | + deployment_type = var.deployment_type |
| 91 | + database_resource_type = var.database_insight_database_resource_type |
| 92 | + credential_details { |
| 93 | + credential_type = var.database_insight_credential_details_credential_type |
| 94 | + password_secret_id = var.secret_id |
| 95 | + role = var.database_insight_credential_details_role |
| 96 | + user_name = var.user_name |
| 97 | + } |
| 98 | + defined_tags = "${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.database_insight_defined_tags_value}")}" |
| 99 | + freeform_tags = var.database_insight_freeform_tags |
| 100 | + status = var.resource_status |
| 101 | +} |
| 102 | + |
| 103 | +variable "database_insight_state" { |
| 104 | + default = ["ACTIVE"] |
| 105 | +} |
| 106 | + |
| 107 | +variable "database_insight_status" { |
| 108 | + default = ["ENABLED"] |
| 109 | +} |
| 110 | + |
| 111 | +// List PE comanaged database insights |
| 112 | +data "oci_opsi_database_insights" "test_database_insights" { |
| 113 | + #Optional |
| 114 | + compartment_id = var.compartment_ocid |
| 115 | + database_type = var.database_insight_database_type |
| 116 | + opsi_private_endpoint_id = var.opsi_private_endpoint_id |
| 117 | + fields = var.database_insight_fields |
| 118 | + state = var.database_insight_state |
| 119 | + status = var.database_insight_status |
| 120 | +} |
| 121 | + |
| 122 | +// Get an EM managed database insight |
| 123 | +data "oci_opsi_database_insight" "test_database_insight" { |
| 124 | + database_insight_id = oci_opsi_database_insight.test_database_insight.id |
| 125 | +} |
| 126 | + |
0 commit comments