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+
11+ variable "em_warehouse_defined_tags_value" {
12+ default = " value"
13+ }
14+
15+ variable "em_warehouse_display_name" {
16+ default = " displayName"
17+ }
18+
19+ variable "em_warehouse_freeform_tags" {
20+ default = { " bar-key" = " value" }
21+ }
22+
23+ variable "em_warehouse_state" {
24+ default = " ACTIVE"
25+ }
26+
27+
28+
29+ provider "oci" {
30+ tenancy_ocid = var. tenancy_ocid
31+ user_ocid = var. user_ocid
32+ fingerprint = var. fingerprint
33+ private_key_path = var. private_key_path
34+ region = var. region
35+ }
36+
37+ resource "oci_identity_tag_namespace" "tag-namespace1" {
38+ compartment_id = var. tenancy_ocid
39+ description = " example tag namespace"
40+ name = " examples-tag-namespace-all"
41+ is_retired = false
42+ }
43+
44+ resource "oci_identity_tag" "tag1" {
45+ description = " example tag"
46+ name = " example-tag"
47+ tag_namespace_id = oci_identity_tag_namespace. tag-namespace1 . id
48+ is_cost_tracking = false
49+ is_retired = false
50+ }
51+
52+ variable "warehouse_defined_tags_value" {
53+ default = " warehouse_tag_value"
54+ }
55+
56+ variable "warehouse_freeform_tags" {
57+ default = { " bar-key" = " value" }
58+ }
59+
60+ variable "warehouse_display_name" {
61+ default = " TestWarehouseDisplayName"
62+ }
63+
64+ variable "warehouse_cpu_allocated" {
65+ default = 1.0
66+ }
67+
68+ variable "storage_allocated_in_gbs" {
69+ default = 1.0
70+ }
71+
72+ // To Create a OPSI Warehouse
73+ resource "oci_opsi_operations_insights_warehouse" "test_operations_insights_warehouse" {
74+ # Required
75+ compartment_id = var. compartment_ocid
76+ cpu_allocated = var. warehouse_cpu_allocated
77+ display_name = var. warehouse_display_name
78+
79+ # Optional
80+ defined_tags = " ${ map (" ${ oci_identity_tag_namespace . tag-namespace1 . name } .${ oci_identity_tag . tag1 . name } " , " ${ var . warehouse_defined_tags_value } " )} "
81+ freeform_tags = var. warehouse_freeform_tags
82+ storage_allocated_in_gbs = var. storage_allocated_in_gbs
83+ }
84+
85+ data "oci_objectstorage_namespace" "test_namespace" {
86+ compartment_id = var. compartment_ocid
87+ }
88+
89+ variable "bucket_name" {
90+ default = " em_data_collection_bucket"
91+ }
92+
93+ resource "oci_objectstorage_bucket" "test_bucket" {
94+ name = var. bucket_name
95+ compartment_id = var. compartment_ocid
96+ namespace = data. oci_objectstorage_namespace . test_namespace . namespace
97+ }
98+
99+ variable "enterprise_manager_bridge_defined_tags_value" {
100+ default = " embridge_tag_value"
101+ }
102+
103+ variable "enterprise_manager_bridge_description" {
104+ default = " Test EM Bridge Description"
105+ }
106+
107+ variable "enterprise_manager_bridge_display_name" {
108+ default = " TestEMManagedBridgeName"
109+ }
110+
111+ variable "enterprise_manager_bridge_freeform_tags" {
112+ default = { " bar-key" = " value" }
113+ }
114+
115+ variable "enterprise_manager_bridge_state" {
116+ default = [" ACTIVE" ]
117+ }
118+
119+ variable "compartment_id_in_subtree" {
120+ default = true
121+ }
122+
123+ // To Create a Enterprise Manager Bridge
124+ resource "oci_opsi_enterprise_manager_bridge" "test_enterprise_manager_bridge" {
125+ # Required
126+ compartment_id = var. compartment_ocid
127+ display_name = var. enterprise_manager_bridge_display_name
128+ object_storage_bucket_name = oci_objectstorage_bucket. test_bucket . name
129+
130+ # Optional
131+ defined_tags = " ${ map (" ${ oci_identity_tag_namespace . tag-namespace1 . name } .${ oci_identity_tag . tag1 . name } " , " ${ var . enterprise_manager_bridge_defined_tags_value } " )} "
132+ freeform_tags = var. enterprise_manager_bridge_freeform_tags
133+ description = var. enterprise_manager_bridge_description
134+ }
135+
136+ // To Create a Enterprise Manager Warehouse
137+ resource "oci_em_warehouse_em_warehouse" "test_em_warehouse" {
138+ # Required
139+ compartment_id = var. compartment_ocid
140+ em_bridge_id = oci_opsi_enterprise_manager_bridge. test_enterprise_manager_bridge . id
141+ operations_insights_warehouse_id = oci_opsi_operations_insights_warehouse. test_operations_insights_warehouse . id
142+
143+ # Optional
144+ defined_tags = " ${ map (" ${ oci_identity_tag_namespace . tag-namespace1 . name } .${ oci_identity_tag . tag1 . name } " , " ${ var . em_warehouse_defined_tags_value } " )} "
145+ display_name = var. em_warehouse_display_name
146+ freeform_tags = var. em_warehouse_freeform_tags
147+ }
148+
149+ // List emWarehouses present under a compartment
150+ data "oci_em_warehouse_em_warehouses" "test_em_warehouses" {
151+ # Required
152+ compartment_id = var. compartment_ocid
153+
154+ # Optional
155+ display_name = var. em_warehouse_display_name
156+ id = oci_em_warehouse_em_warehouse. test_em_warehouse . id
157+ operations_insights_warehouse_id = oci_opsi_operations_insights_warehouse. test_operations_insights_warehouse . id
158+ state = var. em_warehouse_state
159+ }
160+
161+ // Get emWarehouse for a particular id
162+ data "oci_em_warehouse_em_warehouse" "test_em_warehouse" {
163+ # Required
164+ em_warehouse_id = oci_em_warehouse_em_warehouse. test_em_warehouse . id
165+ }
166+
167+ // Get ETL Runs for a particular emWarehouseId
168+ data "oci_em_warehouse_em_warehouse_etl_runs" "test_em_warehouse_etl_runs" {
169+ # Required
170+ em_warehouse_id = oci_em_warehouse_em_warehouse. test_em_warehouse . id
171+ }
172+
173+ // Get Resource Usage for a particular emWarehouseId
174+ data "oci_em_warehouse_em_warehouse_resource_usage" "test_em_warehouse_resource_usage" {
175+ # Required
176+ em_warehouse_id = oci_em_warehouse_em_warehouse. test_em_warehouse . id
177+ }
0 commit comments