|
| 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 "opsi_configuration_config_item_custom_status" { |
| 12 | + default = ["customized"] |
| 13 | +} |
| 14 | + |
| 15 | +variable "opsi_configuration_config_item_field" { |
| 16 | + default = ["metadata", "name", "value", "defaultValue"] |
| 17 | +} |
| 18 | + |
| 19 | +variable "opsi_effective_configuration_config_item_field" { |
| 20 | + default = ["metadata", "name", "value", "defaultValue", "valueSourceConfig"] |
| 21 | +} |
| 22 | + |
| 23 | +variable "opsi_configuration_config_items_config_item_type" { |
| 24 | + default = "BASIC" |
| 25 | +} |
| 26 | + |
| 27 | +variable "opsi_configuration_config_items_name1" { |
| 28 | + default = "dbHighCpuThreshold" |
| 29 | +} |
| 30 | + |
| 31 | +variable "opsi_configuration_config_items_name2" { |
| 32 | + default = "dbHighMemoryThreshold" |
| 33 | +} |
| 34 | + |
| 35 | +variable "opsi_configuration_config_items_value1" { |
| 36 | + default = "83" |
| 37 | +} |
| 38 | + |
| 39 | +variable "opsi_configuration_config_items_value2" { |
| 40 | + default = "72" |
| 41 | +} |
| 42 | + |
| 43 | +variable "opsi_configuration_config_items_applicable_context" { |
| 44 | + default = ["DB_CAPACITY_PLANNING"] |
| 45 | +} |
| 46 | + |
| 47 | +variable "opsi_configuration_defined_tags_value" { |
| 48 | + default = "value" |
| 49 | +} |
| 50 | + |
| 51 | +variable "opsi_configuration_description" { |
| 52 | + default = "description" |
| 53 | +} |
| 54 | + |
| 55 | +variable "opsi_configuration_display_name" { |
| 56 | + default = "displayName" |
| 57 | +} |
| 58 | + |
| 59 | +variable "opsi_configuration_freeform_tags" { |
| 60 | + default = { "bar-key" = "value" } |
| 61 | +} |
| 62 | + |
| 63 | +variable "opsi_configuration_opsi_config_field" { |
| 64 | + default = ["configItems"] |
| 65 | +} |
| 66 | + |
| 67 | +variable "opsi_configuration_opsi_config_type_arr" { |
| 68 | + default = ["UX_CONFIGURATION"] |
| 69 | +} |
| 70 | + |
| 71 | +variable "opsi_configuration_opsi_config_type" { |
| 72 | + default = "UX_CONFIGURATION" |
| 73 | +} |
| 74 | + |
| 75 | +variable "opsi_configuration_state" { |
| 76 | + default = ["ACTIVE"] |
| 77 | +} |
| 78 | + |
| 79 | +variable "opsi_configuration_system_tags" { |
| 80 | + default = "value" |
| 81 | +} |
| 82 | + |
| 83 | +provider "oci" { |
| 84 | + tenancy_ocid = var.tenancy_ocid |
| 85 | + user_ocid = var.user_ocid |
| 86 | + fingerprint = var.fingerprint |
| 87 | + private_key_path = var.private_key_path |
| 88 | + region = var.region |
| 89 | +} |
| 90 | + |
| 91 | +// Create custom Opsi configuration |
| 92 | +resource "oci_opsi_opsi_configuration" "test_opsi_configuration" { |
| 93 | + opsi_config_type = var.opsi_configuration_opsi_config_type |
| 94 | + compartment_id = var.compartment_ocid |
| 95 | + config_item_custom_status = var.opsi_configuration_config_item_custom_status |
| 96 | + config_item_field = var.opsi_configuration_config_item_field |
| 97 | + config_items { |
| 98 | + config_item_type = var.opsi_configuration_config_items_config_item_type |
| 99 | + name = var.opsi_configuration_config_items_name1 |
| 100 | + value = var.opsi_configuration_config_items_value1 |
| 101 | + } |
| 102 | + config_items { |
| 103 | + config_item_type = var.opsi_configuration_config_items_config_item_type |
| 104 | + name = var.opsi_configuration_config_items_name2 |
| 105 | + value = var.opsi_configuration_config_items_value2 |
| 106 | + } |
| 107 | + config_items_applicable_context = var.opsi_configuration_config_items_applicable_context |
| 108 | + description = var.opsi_configuration_description |
| 109 | + display_name = var.opsi_configuration_display_name |
| 110 | + opsi_config_field = var.opsi_configuration_opsi_config_field |
| 111 | +} |
| 112 | + |
| 113 | +// List opsi configuration in compartment |
| 114 | +data "oci_opsi_opsi_configurations" "test_opsi_configurations" { |
| 115 | + compartment_id = var.compartment_ocid |
| 116 | + display_name = var.opsi_configuration_display_name |
| 117 | + opsi_config_type = var.opsi_configuration_opsi_config_type_arr |
| 118 | + state = var.opsi_configuration_state |
| 119 | +} |
| 120 | + |
| 121 | +// Get opsi configuration by id |
| 122 | +data "oci_opsi_opsi_configuration" "test_opsi_configuration" { |
| 123 | + opsi_configuration_id = oci_opsi_opsi_configuration.test_opsi_configuration.id |
| 124 | + config_item_custom_status = var.opsi_configuration_config_item_custom_status |
| 125 | + config_item_field = var.opsi_configuration_config_item_field |
| 126 | + opsi_config_field = var.opsi_configuration_opsi_config_field |
| 127 | + config_items_applicable_context = var.opsi_configuration_config_items_applicable_context |
| 128 | +} |
| 129 | + |
| 130 | +// Get effective opsi configuration for a compartment |
| 131 | +data "oci_opsi_opsi_configuration_configuration_item" "test_opsi_configuration_configuration_item" { |
| 132 | + compartment_id = var.compartment_ocid |
| 133 | + config_item_field = var.opsi_effective_configuration_config_item_field |
| 134 | + config_items_applicable_context = var.opsi_configuration_config_items_applicable_context |
| 135 | + opsi_config_type = var.opsi_configuration_opsi_config_type |
| 136 | +} |
| 137 | + |
0 commit comments