diff --git a/internal/services/hdinsight/hdinsight_interactive_query_cluster_resource.go b/internal/services/hdinsight/hdinsight_interactive_query_cluster_resource.go index c6e18ecc7ea7..f83c6b0ae370 100644 --- a/internal/services/hdinsight/hdinsight_interactive_query_cluster_resource.go +++ b/internal/services/hdinsight/hdinsight_interactive_query_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" @@ -45,7 +46,7 @@ var hdInsightInteractiveQueryClusterZookeeperNodeDefinition = HDInsightNodeDefin } func resourceHDInsightInteractiveQueryCluster() *pluginsdk.Resource { - return &pluginsdk.Resource{ + resource := &pluginsdk.Resource{ Create: resourceHDInsightInteractiveQueryClusterCreate, Read: resourceHDInsightInteractiveQueryClusterRead, Update: hdinsightClusterUpdate("Interactive Query", resourceHDInsightInteractiveQueryClusterRead), @@ -114,21 +115,6 @@ func resourceHDInsightInteractiveQueryCluster() *pluginsdk.Resource { "storage_account_gen2": SchemaHDInsightsGen2StorageAccounts(), - "roles": { - Type: pluginsdk.TypeList, - Required: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightInteractiveQueryClusterHeadNodeDefinition, true), - - "worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true), - - "zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true), - }, - }, - }, - "tags": tags.Schema(), "https_endpoint": { @@ -146,6 +132,42 @@ func resourceHDInsightInteractiveQueryCluster() *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", hdInsightInteractiveQueryClusterHeadNodeDefinition, true), + + "worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true), + + "zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true), + }, + }, + Deprecated: "HDInsight interactive query clusters can no longer be configured through `autoscale.0.capacity`. Use `autoscale.0.recurrence` instead.", + } + } else { + hdInsightInteractiveQueryClusterWorkerNodeDefinition.CanAutoScaleByCapacity = false + 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", hdInsightInteractiveQueryClusterHeadNodeDefinition, true), + + "worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true), + + "zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true), + }, + }, + } + } + + return resource } func resourceHDInsightInteractiveQueryClusterCreate(d *pluginsdk.ResourceData, meta interface{}) error { diff --git a/internal/services/hdinsight/hdinsight_interactive_query_cluster_resource_test.go b/internal/services/hdinsight/hdinsight_interactive_query_cluster_resource_test.go index 474f3fead387..5db36fa35cb9 100644 --- a/internal/services/hdinsight/hdinsight_interactive_query_cluster_resource_test.go +++ b/internal/services/hdinsight/hdinsight_interactive_query_cluster_resource_test.go @@ -567,21 +567,6 @@ func TestAccAzureRMHDInsightInteractiveQueryCluster_autoscale(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_hdinsight_interactive_query_cluster", "test") r := HDInsightInteractiveQueryClusterResource{} data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.autoscale_capacity(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("https_endpoint").Exists(), - check.That(data.ResourceName).Key("ssh_endpoint").Exists(), - ), - }, - data.ImportStep("roles.0.head_node.0.password", - "roles.0.head_node.0.vm_size", - "roles.0.worker_node.0.password", - "roles.0.worker_node.0.vm_size", - "roles.0.zookeeper_node.0.password", - "roles.0.zookeeper_node.0.vm_size", - "storage_account"), { Config: r.autoscale_schedule(data), Check: acceptance.ComposeTestCheckFunc( @@ -2006,55 +1991,6 @@ resource "azurerm_hdinsight_interactive_query_cluster" "test" { `, r.template(data), data.RandomString, data.RandomInteger, data.RandomInteger) } -func (r HDInsightInteractiveQueryClusterResource) autoscale_capacity(data acceptance.TestData) string { - return fmt.Sprintf(` -%s -resource "azurerm_hdinsight_interactive_query_cluster" "test" { - name = "acctesthdi-%d" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - cluster_version = "4.0" - tier = "Standard" - component_version { - interactive_hive = "3.1" - } - gateway { - username = "acctestusrgw" - password = "TerrAform123!" - } - storage_account { - storage_container_id = azurerm_storage_container.test.id - storage_account_key = azurerm_storage_account.test.primary_access_key - is_default = true - } - roles { - head_node { - vm_size = "Standard_D13_V2" - username = "acctestusrvm" - password = "AccTestvdSC4daf986!" - } - worker_node { - vm_size = "Standard_D14_V2" - username = "acctestusrvm" - password = "AccTestvdSC4daf986!" - target_instance_count = 2 - autoscale { - capacity { - min_instance_count = 2 - max_instance_count = 3 - } - } - } - zookeeper_node { - vm_size = "Standard_A4_V2" - username = "acctestusrvm" - password = "AccTestvdSC4daf986!" - } - } -} -`, r.template(data), data.RandomInteger) -} - func (r HDInsightInteractiveQueryClusterResource) autoscale_schedule(data acceptance.TestData) string { return fmt.Sprintf(` %s diff --git a/website/docs/r/hdinsight_interactive_query_cluster.html.markdown b/website/docs/r/hdinsight_interactive_query_cluster.html.markdown index 1af03b06fa10..028ed17fe5a0 100644 --- a/website/docs/r/hdinsight_interactive_query_cluster.html.markdown +++ b/website/docs/r/hdinsight_interactive_query_cluster.html.markdown @@ -363,20 +363,8 @@ A `extension` block supports the following: An `autoscale` block supports the following: -* `capacity` - (Optional) A `capacity` block as defined below. - * `recurrence` - (Optional) A `recurrence` block as defined below. --> **NOTE:** Either a `capacity` or `recurrence` block must be specified - but not both. - ---- - -A `capacity` block supports the following: - -* `max_instance_count` - (Required) The maximum number of worker nodes to autoscale to based on the cluster's activity. - -* `min_instance_count` - (Required) The minimum number of worker nodes to autoscale to based on the cluster's activity. - --- A `recurrence` block supports the following: