Skip to content

Commit

Permalink
Merge pull request #5717 from terraform-providers/web-2.0
Browse files Browse the repository at this point in the history
2.0: removing deprecated properties from `web`
  • Loading branch information
tombuildsstuff authored Feb 13, 2020
2 parents e688c3b + 3ed3a3f commit cdb9a49
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 143 deletions.
36 changes: 16 additions & 20 deletions azurerm/internal/services/web/data_source_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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))
Expand Down
106 changes: 8 additions & 98 deletions azurerm/internal/services/web/resource_arm_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
Expand All @@ -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"),
),
Expand Down Expand Up @@ -142,9 +138,7 @@ resource "azurerm_app_service_plan" "test" {
size = "S1"
}
properties {
per_site_scaling = true
}
per_site_scaling = true
tags = {
environment = "Test"
Expand Down Expand Up @@ -177,9 +171,7 @@ resource "azurerm_app_service_plan" "test" {
size = "EP1"
}
properties {
per_site_scaling = true
}
per_site_scaling = true
tags = {
environment = "Test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down
19 changes: 7 additions & 12 deletions website/docs/d/app_service_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion website/docs/guides/2.0-upgrade-guide.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cdb9a49

Please sign in to comment.