Skip to content

Commit

Permalink
Merge pull request #850 from terraform-providers/app-service-plan-env-id
Browse files Browse the repository at this point in the history
App Service Plan: support for attaching to an App Service Environment
  • Loading branch information
tombuildsstuff authored Feb 17, 2018
2 parents 7fee64d + 162801b commit 2179094
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions azurerm/data_source_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions azurerm/resource_arm_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand All @@ -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
}
Expand Down
9 changes: 7 additions & 2 deletions website/docs/d/app_service_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
4 changes: 4 additions & 0 deletions website/docs/r/app_service_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 2179094

Please sign in to comment.