From 0861c966244131c341053648cafc02c22e466dd4 Mon Sep 17 00:00:00 2001 From: Jiawei Tao Date: Thu, 24 Nov 2022 16:32:47 +0800 Subject: [PATCH] hdinsight_kafka_cluster_resource: deprecate kafka_management_node --- .../hdinsight_kafka_cluster_resource.go | 46 ++++++++++++++++++- .../r/hdinsight_kafka_cluster.html.markdown | 2 + 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/internal/services/hdinsight/hdinsight_kafka_cluster_resource.go b/internal/services/hdinsight/hdinsight_kafka_cluster_resource.go index 6a3b9cdae5fe..8dcede579a8f 100644 --- a/internal/services/hdinsight/hdinsight_kafka_cluster_resource.go +++ b/internal/services/hdinsight/hdinsight_kafka_cluster_resource.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/hdinsight/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -52,7 +53,7 @@ var hdInsightKafkaClusterKafkaManagementNodeDefinition = HDInsightNodeDefinition } func resourceHDInsightKafkaCluster() *pluginsdk.Resource { - return &pluginsdk.Resource{ + resource := &pluginsdk.Resource{ Create: resourceHDInsightKafkaClusterCreate, Read: resourceHDInsightKafkaClusterRead, Update: hdinsightClusterUpdate("Kafka", resourceHDInsightKafkaClusterRead), @@ -158,7 +159,12 @@ func resourceHDInsightKafkaCluster() *pluginsdk.Resource { }, }, }, - RequiredWith: []string{"roles.0.kafka_management_node"}, + RequiredWith: func() []string { + if !features.FourPointOh() { + return []string{"roles.0.kafka_management_node"} + } + return []string{} + }(), }, "tags": tags.Schema(), @@ -183,6 +189,42 @@ func resourceHDInsightKafkaCluster() *pluginsdk.Resource { "extension": SchemaHDInsightsExtension(), }, } + + if !features.FourPointOh() { + resource.Schema["roles"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeList, + Required: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightKafkaClusterHeadNodeDefinition, true), + + "worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightKafkaClusterWorkerNodeDefinition, true), + + "zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightKafkaClusterZookeeperNodeDefinition, true), + + "kafka_management_node": SchemaHDInsightNodeDefinition("roles.0.kafka_management_node", hdInsightKafkaClusterKafkaManagementNodeDefinition, false), + }, + }, + } + } else { + resource.Schema["roles"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeList, + Required: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightKafkaClusterHeadNodeDefinition, true), + + "worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightKafkaClusterWorkerNodeDefinition, true), + + "zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightKafkaClusterZookeeperNodeDefinition, true), + }, + }, + } + } + + return resource } func resourceHDInsightKafkaClusterCreate(d *pluginsdk.ResourceData, meta interface{}) error { diff --git a/website/docs/r/hdinsight_kafka_cluster.html.markdown b/website/docs/r/hdinsight_kafka_cluster.html.markdown index 583881c62ef6..b98a52c5693a 100644 --- a/website/docs/r/hdinsight_kafka_cluster.html.markdown +++ b/website/docs/r/hdinsight_kafka_cluster.html.markdown @@ -182,6 +182,8 @@ A `roles` block supports the following: * `kafka_management_node` - (Optional) A `kafka_management_node` block as defined below. + ~> **Note:** This property has been deprecated and will be removed in version 4.0. + --- A `network` block supports the following: