|
| 1 | +// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | +// Licensed under the Mozilla Public License v2.0 |
| 3 | + |
| 4 | +variable config_file_profile { |
| 5 | +} |
| 6 | + |
| 7 | +variable "region" { |
| 8 | +} |
| 9 | + |
| 10 | +variable "compartment_ocid" { |
| 11 | +} |
| 12 | + |
| 13 | +variable "tenancy_ocid" { |
| 14 | +} |
| 15 | + |
| 16 | +variable "project_description" { |
| 17 | + default = "description" |
| 18 | +} |
| 19 | + |
| 20 | +variable "vault_id" { |
| 21 | + |
| 22 | +} |
| 23 | + |
| 24 | +variable "key_id" { |
| 25 | + |
| 26 | +} |
| 27 | + |
| 28 | +variable "subnet" { |
| 29 | + |
| 30 | +} |
| 31 | + |
| 32 | +provider "oci" { |
| 33 | + auth = "SecurityToken" |
| 34 | + config_file_profile = var.config_file_profile |
| 35 | + region = var.region |
| 36 | +} |
| 37 | + |
| 38 | +resource "oci_managed_kafka_kafka_cluster_config" "test_kafka_cluster_config"{ |
| 39 | + compartment_id = var.compartment_ocid |
| 40 | + latest_config { |
| 41 | + properties = { |
| 42 | + "properties" = "properties" |
| 43 | + } |
| 44 | + } |
| 45 | + lifecycle { |
| 46 | + ignore_changes = [defined_tags] |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +data "oci_managed_kafka_kafka_cluster_config_versions" "test_kafka_cluster_config_versions" { |
| 51 | + kafka_cluster_config_id = "${oci_managed_kafka_kafka_cluster_config.test_kafka_cluster_config.id}" |
| 52 | +} |
| 53 | + |
| 54 | + |
| 55 | +data "oci_managed_kafka_kafka_cluster_config_version" "test_kafka_cluster_config_version" { |
| 56 | + kafka_cluster_config_id = "${oci_managed_kafka_kafka_cluster_config.test_kafka_cluster_config.id}" |
| 57 | + version_number = "1" |
| 58 | +} |
| 59 | + |
| 60 | +//DEPENDENCIES |
| 61 | +variable defined_tag_namespace_name { |
| 62 | + default = "" |
| 63 | +} |
| 64 | + |
| 65 | +resource "oci_identity_tag_namespace" "tag-namespace1" { |
| 66 | + #Required |
| 67 | + compartment_id = var.tenancy_ocid |
| 68 | + description = "example tag namespace" |
| 69 | + name = var.defined_tag_namespace_name != "" ? var.defined_tag_namespace_name : "example-tag-namespace-all" |
| 70 | + |
| 71 | + is_retired = false |
| 72 | +} |
| 73 | + |
| 74 | +resource "oci_identity_tag" "tag1" { |
| 75 | + #Required |
| 76 | + description = "example tag" |
| 77 | + name = "example-tag" |
| 78 | + tag_namespace_id = oci_identity_tag_namespace.tag-namespace1.id |
| 79 | + |
| 80 | + is_retired = false |
| 81 | +} |
| 82 | + |
| 83 | +resource "oci_managed_kafka_kafka_cluster_config" "test_kafka_cluster_config_2" { |
| 84 | + compartment_id = var.compartment_ocid |
| 85 | + defined_tags = "${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}" |
| 86 | + display_name = "displayName2" |
| 87 | + |
| 88 | + freeform_tags = { |
| 89 | + "Department" = "Accounting" |
| 90 | + } |
| 91 | + |
| 92 | + latest_config { |
| 93 | + properties = { |
| 94 | + "properties2" = "properties2" |
| 95 | + } |
| 96 | + version_number = "11" |
| 97 | + } |
| 98 | + |
| 99 | + lifecycle { |
| 100 | + ignore_changes = [defined_tags] |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | + |
| 105 | +resource "oci_managed_kafka_kafka_cluster" "test_kafka_cluster" { |
| 106 | + access_subnets { |
| 107 | + subnets = ["${var.subnet}"] |
| 108 | + } |
| 109 | + broker_shape { |
| 110 | + node_count = "3" |
| 111 | + ocpu_count = "2" |
| 112 | + } |
| 113 | + cluster_config_id = "${oci_managed_kafka_kafka_cluster_config.test_kafka_cluster_config.id}" |
| 114 | + cluster_config_version = "1" |
| 115 | + cluster_type = "DEVELOPMENT" |
| 116 | + compartment_id = "${var.compartment_ocid}" |
| 117 | + coordination_type = "ZOOKEEPER" |
| 118 | + kafka_version = "3.7.0" |
| 119 | + lifecycle { |
| 120 | + ignore_changes = ["defined_tags"] |
| 121 | + } |
| 122 | + |
| 123 | + timeouts { |
| 124 | + create = "60m" |
| 125 | + delete = "60m" |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +resource "oci_vault_secret" "test_secrets" { |
| 130 | + compartment_id = "${var.compartment_ocid}" |
| 131 | + key_id = "${var.key_id}" |
| 132 | + secret_content { |
| 133 | + #Required |
| 134 | + content_type = "BASE64" |
| 135 | + #Optional |
| 136 | + content = "PHZhcj4mbHQ7YmFzZTY0X2VuY29kZWRfc2VjcmV0X2NvbnRlbnRzJmd0OzwvdmFyPg==" |
| 137 | + } |
| 138 | + # Secret names should be unique within a vault.if you see an error with 400 name already exists, change name and try again Avoid entering confidential information. |
| 139 | + secret_name = "testsecretname10" |
| 140 | + vault_id = "${var.vault_id}" |
| 141 | +} |
| 142 | + |
| 143 | +resource "oci_managed_kafka_kafka_cluster_superusers_management" "test_kafka_cluster_superusers_management" { |
| 144 | + compartment_id = "${var.compartment_ocid}" |
| 145 | + enable_superuser = "true" |
| 146 | + kafka_cluster_id = "${oci_managed_kafka_kafka_cluster.test_kafka_cluster.id}" |
| 147 | + secret_id = "${oci_vault_secret.test_secrets.id}" |
| 148 | +} |
0 commit comments