diff --git a/azurerm/data_source_app_service_plan.go b/azurerm/data_source_app_service_plan.go index 82ffac4fea76..b3c6761276fe 100644 --- a/azurerm/data_source_app_service_plan.go +++ b/azurerm/data_source_app_service_plan.go @@ -55,6 +55,10 @@ func dataSourceAppServicePlan() *schema.Resource { 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, diff --git a/azurerm/resource_arm_app_service_plan.go b/azurerm/resource_arm_app_service_plan.go index 295d390a5af4..ea9d2054d7ea 100644 --- a/azurerm/resource_arm_app_service_plan.go +++ b/azurerm/resource_arm_app_service_plan.go @@ -75,6 +75,11 @@ func resourceArmAppServicePlan() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "app_service_environment_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, "reserved": { Type: schema.TypeBool, Optional: true, @@ -264,6 +269,13 @@ func expandAppServicePlanProperties(d *schema.ResourceData, name string) *web.Ap } 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) @@ -277,6 +289,10 @@ func flattenAppServiceProperties(props *web.AppServicePlanProperties) []interfac result := make([]interface{}, 0, 1) properties := make(map[string]interface{}, 0) + if props.HostingEnvironmentProfile != nil { + properties["app_service_environment_id"] = *props.HostingEnvironmentProfile.ID + } + if props.PerSiteScaling != nil { properties["per_site_scaling"] = *props.PerSiteScaling } diff --git a/website/docs/d/app_service_plan.html.markdown b/website/docs/d/app_service_plan.html.markdown index 4711cacda55b..32af51a87418 100644 --- a/website/docs/d/app_service_plan.html.markdown +++ b/website/docs/d/app_service_plan.html.markdown @@ -42,6 +42,10 @@ output "app_service_plan_id" { * `tags` - A mapping of tags to assign to the resource. +* `maximum_number_of_workers` - The maximum number of workers supported with the App Service Plan's sku. + +--- + A `sku` block supports the following: * `tier` - Specifies the plan's pricing tier. @@ -50,12 +54,13 @@ 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? - -* `maximum_number_of_workers` - The maximum number of workers supported with the App Service Plan's sku. diff --git a/website/docs/r/app_service_plan.html.markdown b/website/docs/r/app_service_plan.html.markdown index 3730ef2cbb06..5223e829cc12 100644 --- a/website/docs/r/app_service_plan.html.markdown +++ b/website/docs/r/app_service_plan.html.markdown @@ -58,6 +58,10 @@ The following arguments are supported: `properties` supports the following: +* `app_service_environment_id` - (Optional) The ID of the App Service Environment where the App Service Plan should be located. Changing forces a new resource to be created. + +~> **NOTE:** Attaching to an App Service Environment requires the App Service Plan use a `Premium` SKU. + * `maximum_number_of_workers` - (Optional) Maximum number of instances that can be assigned to this App Service plan. * `reserved` - (Optional) Is this App Service Plan `Reserved`. Defaults to `false`.