Skip to content

Commit 12738f3

Browse files
Tawen Kanjotruon
authored andcommitted
Added - Support for OPSI service supporting DBCS featuer
1 parent fd0b7fa commit 12738f3

25 files changed

+3108
-60
lines changed

examples/opsi/database_insight/database_insight.tf renamed to examples/opsi/database_insight/em_managed_database_insight/database_insight.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ variable "resource_status" {
6161

6262
// Create Database insight for EM managed External Database
6363
resource "oci_opsi_database_insight" "test_database_insight" {
64+
#Required
6465
compartment_id = var.compartment_ocid
66+
entity_source = var.database_insight_entity_source
67+
68+
#Optional
6569
enterprise_manager_bridge_id = var.enterprise_manager_bridge_ocid
6670
enterprise_manager_entity_identifier = var.enterprise_manager_entity_id
6771
enterprise_manager_identifier = var.enterprise_manager_id
68-
entity_source = var.database_insight_entity_source
6972
defined_tags = "${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.database_insight_defined_tags_value}")}"
7073
freeform_tags = var.database_insight_freeform_tags
7174
status = var.resource_status
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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 "vcn_id" {}
11+
variable "subnet_id" {}
12+
13+
variable "operations_insights_private_endpoint_compartment_id_in_subtree" {
14+
default = false
15+
}
16+
17+
variable "operations_insights_private_endpoint_defined_tags_value" {
18+
default = "value"
19+
}
20+
21+
variable "operations_insights_private_endpoint_description" {
22+
default = "TestDescription"
23+
}
24+
25+
variable "operations_insights_private_endpoint_display_name" {
26+
default = "TestPrivateEndpoint"
27+
}
28+
29+
variable "operations_insights_private_endpoint_freeform_tags" {
30+
default = { "bar-key" = "value" }
31+
}
32+
33+
variable "operations_insights_private_endpoint_is_used_for_rac_dbs" {
34+
default = false
35+
}
36+
37+
variable "operations_insights_private_endpoint_nsg_ids" {
38+
default = []
39+
}
40+
41+
variable "operations_insights_private_endpoint_state" {
42+
default = ["ACTIVE"]
43+
}
44+
45+
46+
provider "oci" {
47+
tenancy_ocid = var.tenancy_ocid
48+
user_ocid = var.user_ocid
49+
fingerprint = var.fingerprint
50+
private_key_path = var.private_key_path
51+
region = var.region
52+
}
53+
54+
resource "oci_identity_tag_namespace" "tag-namespace1" {
55+
compartment_id = var.tenancy_ocid
56+
description = "example tag namespace"
57+
name = "examples-tag-namespace-all"
58+
is_retired = false
59+
}
60+
61+
resource "oci_identity_tag" "tag1" {
62+
description = "example tag"
63+
name = "example-tag"
64+
tag_namespace_id = oci_identity_tag_namespace.tag-namespace1.id
65+
is_cost_tracking = false
66+
is_retired = false
67+
}
68+
69+
resource "oci_opsi_operations_insights_private_endpoint" "test_operations_insights_private_endpoint" {
70+
compartment_id = var.compartment_ocid
71+
display_name = var.operations_insights_private_endpoint_display_name
72+
description = var.operations_insights_private_endpoint_description
73+
is_used_for_rac_dbs = var.operations_insights_private_endpoint_is_used_for_rac_dbs
74+
subnet_id = var.subnet_id
75+
vcn_id = var.vcn_id
76+
defined_tags = "${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.operations_insights_private_endpoint_defined_tags_value}")}"
77+
freeform_tags = var.operations_insights_private_endpoint_freeform_tags
78+
nsg_ids = var.operations_insights_private_endpoint_nsg_ids
79+
}
80+
81+
data "oci_opsi_operations_insights_private_endpoints" "test_operations_insights_private_endpoints" {
82+
83+
#Optional
84+
compartment_id = var.compartment_ocid
85+
compartment_id_in_subtree = var.operations_insights_private_endpoint_compartment_id_in_subtree
86+
display_name = var.operations_insights_private_endpoint_display_name
87+
is_used_for_rac_dbs = var.operations_insights_private_endpoint_is_used_for_rac_dbs
88+
opsi_private_endpoint_id = oci_opsi_operations_insights_private_endpoint.test_operations_insights_private_endpoint.id
89+
state = var.operations_insights_private_endpoint_state
90+
vcn_id = var.vcn_id
91+
}
92+

internal/integrationtest/opsi_database_insight_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ var (
6262
"entity_source": acctest.Representation{RepType: acctest.Required, Create: `EM_MANAGED_EXTERNAL_DATABASE`, Update: `EM_MANAGED_EXTERNAL_DATABASE`},
6363
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
6464
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
65-
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreChangesdatabaseInsightRepresentation},
65+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreChangesDatabaseInsightRepresentation},
6666
}
6767

68-
ignoreChangesdatabaseInsightRepresentation = map[string]interface{}{
68+
ignoreChangesDatabaseInsightRepresentation = map[string]interface{}{
6969
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`}},
7070
}
7171

0 commit comments

Comments
 (0)