diff --git a/azurerm/internal/services/web/data_source_app_service_plan.go b/azurerm/internal/services/web/data_source_app_service_plan.go index 15a3f778fe0e..5a8013bbb510 100644 --- a/azurerm/internal/services/web/data_source_app_service_plan.go +++ b/azurerm/internal/services/web/data_source_app_service_plan.go @@ -56,25 +56,19 @@ func dataSourceAppServicePlan() *schema.Resource { }, }, - "properties": { - Type: schema.TypeList, + "app_service_environment_id": { + Type: schema.TypeString, + Computed: true, + }, + + "reserved": { + Type: schema.TypeBool, + Computed: true, + }, + + "per_site_scaling": { + Type: schema.TypeBool, Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "app_service_environment_id": { - Type: schema.TypeString, - Computed: true, - }, - "reserved": { - Type: schema.TypeBool, - Computed: true, - }, - "per_site_scaling": { - Type: schema.TypeBool, - Computed: true, - }, - }, - }, }, "maximum_number_of_workers": { @@ -125,9 +119,11 @@ func dataSourceAppServicePlanRead(d *schema.ResourceData, meta interface{}) erro } if props := resp.AppServicePlanProperties; props != nil { - if err := d.Set("properties", flattenAppServiceProperties(props)); err != nil { - return fmt.Errorf("Error setting `properties`: %+v", err) + if profile := props.HostingEnvironmentProfile; profile != nil { + d.Set("app_service_environment_id", profile.ID) } + d.Set("per_site_scaling", props.PerSiteScaling) + d.Set("reserved", props.Reserved) if props.MaximumNumberOfWorkers != nil { d.Set("maximum_number_of_workers", int(*props.MaximumNumberOfWorkers)) diff --git a/azurerm/internal/services/web/resource_arm_app_service_plan.go b/azurerm/internal/services/web/resource_arm_app_service_plan.go index 885ee56dba11..db32dd0b5efd 100644 --- a/azurerm/internal/services/web/resource_arm_app_service_plan.go +++ b/azurerm/internal/services/web/resource_arm_app_service_plan.go @@ -94,63 +94,21 @@ func resourceArmAppServicePlan() *schema.Resource { }, }, - "properties": { - Type: schema.TypeList, - Optional: true, - Computed: true, - MaxItems: 1, - Deprecated: "These properties have been moved to the top level", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "app_service_environment_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, - Deprecated: "This property has been moved to the top level", - ConflictsWith: []string{"app_service_environment_id"}, - }, - - "reserved": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Deprecated: "This property has been moved to the top level", - ConflictsWith: []string{"reserved"}, - }, - - "per_site_scaling": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Deprecated: "This property has been moved to the top level", - ConflictsWith: []string{"per_site_scaling"}, - }, - }, - }, - }, - /// AppServicePlanProperties "app_service_environment_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, - ConflictsWith: []string{"properties.0.app_service_environment_id"}, + Type: schema.TypeString, + Optional: true, + ForceNew: true, }, "per_site_scaling": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - ConflictsWith: []string{"properties.0.per_site_scaling"}, + Type: schema.TypeBool, + Optional: true, }, "reserved": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - ConflictsWith: []string{"properties.0.reserved"}, + Type: schema.TypeBool, + Optional: true, }, "maximum_elastic_worker_count": { @@ -203,7 +161,7 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac t := d.Get("tags").(map[string]interface{}) sku := expandAzureRmAppServicePlanSku(d) - properties := expandAppServicePlanProperties(d) + properties := &web.AppServicePlanProperties{} isXenon := d.Get("is_xenon").(bool) properties.IsXenon = &isXenon @@ -306,10 +264,6 @@ func resourceArmAppServicePlanRead(d *schema.ResourceData, meta interface{}) err d.Set("kind", resp.Kind) if props := resp.AppServicePlanProperties; props != nil { - if err := d.Set("properties", flattenAppServiceProperties(props)); err != nil { - return fmt.Errorf("Error setting `properties`: %+v", err) - } - if profile := props.HostingEnvironmentProfile; profile != nil { d.Set("app_service_environment_id", profile.ID) } @@ -404,50 +358,6 @@ func flattenAppServicePlanSku(input *web.SkuDescription) []interface{} { return outputs } -func expandAppServicePlanProperties(d *schema.ResourceData) *web.AppServicePlanProperties { - configs := d.Get("properties").([]interface{}) - properties := web.AppServicePlanProperties{} - if len(configs) == 0 { - return &properties - } - config := configs[0].(map[string]interface{}) - - appServiceEnvironmentId := config["app_service_environment_id"].(string) - if appServiceEnvironmentId != "" { - properties.HostingEnvironmentProfile = &web.HostingEnvironmentProfile{ - ID: utils.String(appServiceEnvironmentId), - } - } - - perSiteScaling := config["per_site_scaling"].(bool) - properties.PerSiteScaling = utils.Bool(perSiteScaling) - - reserved := config["reserved"].(bool) - properties.Reserved = utils.Bool(reserved) - - return &properties -} - -func flattenAppServiceProperties(props *web.AppServicePlanProperties) []interface{} { - result := make([]interface{}, 0, 1) - properties := make(map[string]interface{}) - - if props.HostingEnvironmentProfile != nil && props.HostingEnvironmentProfile.ID != nil { - properties["app_service_environment_id"] = *props.HostingEnvironmentProfile.ID - } - - if props.PerSiteScaling != nil { - properties["per_site_scaling"] = *props.PerSiteScaling - } - - if props.Reserved != nil { - properties["reserved"] = *props.Reserved - } - - result = append(result, properties) - return result -} - func validateAppServicePlanName(v interface{}, k string) (warnings []string, errors []error) { value := v.(string) diff --git a/azurerm/internal/services/web/tests/data_source_app_service_plan_test.go b/azurerm/internal/services/web/tests/data_source_app_service_plan_test.go index f55157e01d6d..0b6d291c9d01 100644 --- a/azurerm/internal/services/web/tests/data_source_app_service_plan_test.go +++ b/azurerm/internal/services/web/tests/data_source_app_service_plan_test.go @@ -24,8 +24,6 @@ func TestAccDataSourceAzureRMAppServicePlan_basic(t *testing.T) { resource.TestCheckResourceAttr(data.ResourceName, "sku.#", "1"), resource.TestCheckResourceAttr(data.ResourceName, "sku.0.tier", "Basic"), resource.TestCheckResourceAttr(data.ResourceName, "sku.0.size", "B1"), - resource.TestCheckResourceAttr(data.ResourceName, "properties.#", "1"), - resource.TestCheckResourceAttr(data.ResourceName, "properties.0.per_site_scaling", "false"), resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "0"), ), }, @@ -47,8 +45,6 @@ func TestAccDataSourceAzureRMAppServicePlan_complete(t *testing.T) { resource.TestCheckResourceAttr(data.ResourceName, "sku.#", "1"), resource.TestCheckResourceAttr(data.ResourceName, "sku.0.tier", "Standard"), resource.TestCheckResourceAttr(data.ResourceName, "sku.0.size", "S1"), - resource.TestCheckResourceAttr(data.ResourceName, "properties.#", "1"), - resource.TestCheckResourceAttr(data.ResourceName, "properties.0.per_site_scaling", "true"), resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), resource.TestCheckResourceAttr(data.ResourceName, "tags.environment", "Test"), ), @@ -142,9 +138,7 @@ resource "azurerm_app_service_plan" "test" { size = "S1" } - properties { - per_site_scaling = true - } + per_site_scaling = true tags = { environment = "Test" @@ -177,9 +171,7 @@ resource "azurerm_app_service_plan" "test" { size = "EP1" } - properties { - per_site_scaling = true - } + per_site_scaling = true tags = { environment = "Test" diff --git a/azurerm/internal/services/web/tests/resource_arm_app_service_plan_test.go b/azurerm/internal/services/web/tests/resource_arm_app_service_plan_test.go index d8b79ede8998..762048d93412 100644 --- a/azurerm/internal/services/web/tests/resource_arm_app_service_plan_test.go +++ b/azurerm/internal/services/web/tests/resource_arm_app_service_plan_test.go @@ -165,8 +165,8 @@ func TestAccAzureRMAppServicePlan_completeWindows(t *testing.T) { Config: testAccAzureRMAppServicePlan_completeWindows(data), Check: resource.ComposeTestCheckFunc( testCheckAzureRMAppServicePlanExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "properties.0.per_site_scaling", "true"), - resource.TestCheckResourceAttr(data.ResourceName, "properties.0.reserved", "false"), + resource.TestCheckResourceAttr(data.ResourceName, "per_site_scaling", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "reserved", "false"), ), }, { diff --git a/website/docs/d/app_service_plan.html.markdown b/website/docs/d/app_service_plan.html.markdown index 47763f230f82..bbdb17853c2e 100644 --- a/website/docs/d/app_service_plan.html.markdown +++ b/website/docs/d/app_service_plan.html.markdown @@ -38,7 +38,13 @@ output "app_service_plan_id" { * `sku` - A `sku` block as documented below. -* `properties` - A `properties` block as documented below. +* `app_service_environment_id` - The ID of the App Service Environment where the App Service Plan is located. + +* `maximum_number_of_workers` - Maximum number of instances that can be assigned to this App Service plan. + +* `reserved` - Is this App Service Plan `Reserved`? + +* `per_site_scaling` - Can Apps assigned to this App Service Plan be scaled independently? * `tags` - A mapping of tags assigned to the resource. @@ -58,17 +64,6 @@ A `sku` block supports the following: * `capacity` - Specifies the number of workers associated with this App Service Plan. - -A `properties` block supports the following: - -* `app_service_environment_id` - The ID of the App Service Environment where the App Service Plan is located. - -* `maximum_number_of_workers` - Maximum number of instances that can be assigned to this App Service plan. - -* `reserved` - Is this App Service Plan `Reserved`? - -* `per_site_scaling` - Can Apps assigned to this App Service Plan be scaled independently? - ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: diff --git a/website/docs/guides/2.0-upgrade-guide.html.markdown b/website/docs/guides/2.0-upgrade-guide.html.markdown index 5b3d7ed7fa4e..14bec6f0c9b3 100644 --- a/website/docs/guides/2.0-upgrade-guide.html.markdown +++ b/website/docs/guides/2.0-upgrade-guide.html.markdown @@ -147,10 +147,14 @@ The AzureAD Data Sources and Resources have been moved to [the new AzureAD Provi A guide on how to migrate to using the new Provider [can be found here](https://www.terraform.io/docs/providers/azurerm/guides/migrating-to-azuread.html). -### Data Soure: `azurerm_api_management` +### Data Source: `azurerm_api_management` The deprecated field `sku` will be removed in favour of the `sku_name` property. +### Data Source: `azurerm_app_service_plan` + +The fields in the `properties` block (`app_service_environment_id`, `reserved` and `per_site_scaling`) have been moved to the top level - as such the `properties` block will be removed. + ### Data Source: `azurerm_client_config` The deprecated fields `service_principal_object_id` and `service_principal_application_id` will be removed. They have been replaced with the `object_id` and `client_id` respectively.