|
| 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 "enterprise_manager_bridge_ocid" {} |
| 11 | +variable "enterprise_manager_entity_id" {} |
| 12 | +variable "enterprise_manager_id" {} |
| 13 | + |
| 14 | +provider "oci" { |
| 15 | + tenancy_ocid = var.tenancy_ocid |
| 16 | + user_ocid = var.user_ocid |
| 17 | + fingerprint = var.fingerprint |
| 18 | + private_key_path = var.private_key_path |
| 19 | + region = var.region |
| 20 | +} |
| 21 | + |
| 22 | +resource "oci_identity_tag_namespace" "tag-namespace1" { |
| 23 | + compartment_id = var.tenancy_ocid |
| 24 | + description = "example tag namespace" |
| 25 | + name = "examples-tag-namespace-all" |
| 26 | + is_retired = false |
| 27 | +} |
| 28 | + |
| 29 | + |
| 30 | +resource "oci_identity_tag" "tag1" { |
| 31 | + description = "example tag" |
| 32 | + name = "example-tag" |
| 33 | + tag_namespace_id = oci_identity_tag_namespace.tag-namespace1.id |
| 34 | + is_cost_tracking = false |
| 35 | + is_retired = false |
| 36 | +} |
| 37 | + |
| 38 | +variable "database_insight_database_type" { |
| 39 | + default = ["EXTERNAL-NONCDB"] |
| 40 | +} |
| 41 | + |
| 42 | +variable "database_insight_defined_tags_value" { |
| 43 | + default = "value" |
| 44 | +} |
| 45 | + |
| 46 | +variable "database_insight_entity_source" { |
| 47 | + default = "EM_MANAGED_EXTERNAL_DATABASE" |
| 48 | +} |
| 49 | + |
| 50 | +variable "database_insight_fields" { |
| 51 | + default = ["databaseName", "databaseType", "compartmentId", "databaseDisplayName", "freeformTags", "definedTags", "systemTags"] |
| 52 | +} |
| 53 | + |
| 54 | +variable "database_insight_freeform_tags" { |
| 55 | + default = { "bar-key" = "value" } |
| 56 | +} |
| 57 | + |
| 58 | +variable "resource_status" { |
| 59 | + default = "ENABLED" |
| 60 | +} |
| 61 | + |
| 62 | +// Create Database insight for EM managed External Database |
| 63 | +resource "oci_opsi_database_insight" "test_database_insight" { |
| 64 | + compartment_id = var.compartment_ocid |
| 65 | + enterprise_manager_bridge_id = var.enterprise_manager_bridge_ocid |
| 66 | + enterprise_manager_entity_identifier = var.enterprise_manager_entity_id |
| 67 | + enterprise_manager_identifier = var.enterprise_manager_id |
| 68 | + entity_source = var.database_insight_entity_source |
| 69 | + defined_tags = "${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.database_insight_defined_tags_value}")}" |
| 70 | + freeform_tags = var.database_insight_freeform_tags |
| 71 | + status = var.resource_status |
| 72 | +} |
| 73 | + |
| 74 | +variable "database_insight_state" { |
| 75 | + default = ["ACTIVE"] |
| 76 | +} |
| 77 | + |
| 78 | +variable "database_insight_status" { |
| 79 | + default = ["ENABLED"] |
| 80 | +} |
| 81 | + |
| 82 | +// List EM managed database insights |
| 83 | +data "oci_opsi_database_insights" "test_database_insights" { |
| 84 | + |
| 85 | + #Optional |
| 86 | + compartment_id = var.compartment_ocid |
| 87 | + database_type = var.database_insight_database_type |
| 88 | + enterprise_manager_bridge_id = var.enterprise_manager_bridge_ocid |
| 89 | + fields = var.database_insight_fields |
| 90 | + state = var.database_insight_state |
| 91 | + status = var.database_insight_status |
| 92 | +} |
| 93 | + |
| 94 | +// Get an EM managed database insight |
| 95 | +data "oci_opsi_database_insight" "test_database_insight" { |
| 96 | + database_insight_id = oci_opsi_database_insight.test_database_insight.id |
| 97 | +} |
| 98 | + |
0 commit comments