Skip to content

Commit

Permalink
provider/aws: Add maximum_elastic_worker_count to app_service_plan
Browse files Browse the repository at this point in the history
  • Loading branch information
stack72 committed Jun 4, 2019
1 parent 7dc945c commit 0f66fd7
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 2 deletions.
9 changes: 9 additions & 0 deletions azurerm/data_source_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ func dataSourceAppServicePlan() *schema.Resource {
Computed: true,
},

"maximum_elastic_worker_count": {
Type: schema.TypeInt,
Computed: true,
},

"is_xenon": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -119,6 +124,10 @@ func dataSourceAppServicePlanRead(d *schema.ResourceData, meta interface{}) erro
if props.MaximumNumberOfWorkers != nil {
d.Set("maximum_number_of_workers", int(*props.MaximumNumberOfWorkers))
}

if props.MaximumElasticWorkerCount != nil {
d.Set("maximum_elastic_worker_count", int(*props.MaximumElasticWorkerCount))
}
}

if err := d.Set("sku", flattenAppServicePlanSku(resp.Sku)); err != nil {
Expand Down
58 changes: 58 additions & 0 deletions azurerm/data_source_app_service_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@ func TestAccDataSourceAzureRMAppServicePlan_complete(t *testing.T) {
})
}

func TestAccDataSourceAzureRMAppServicePlan_premiumSKU(t *testing.T) {
dataSourceName := "data.azurerm_app_service_plan.test"
rInt := tf.AccRandTimeInt()
location := testLocation()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAppServicePlan_premiumSKU(rInt, location),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "kind", "elastic"),
resource.TestCheckResourceAttr(dataSourceName, "sku.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "sku.0.tier", "ElasticPremium"),
resource.TestCheckResourceAttr(dataSourceName, "sku.0.size", "EP1"),
resource.TestCheckResourceAttr(dataSourceName, "maximum_elastic_worker_count", "20"),
),
},
},
})
}

func TestAccDataSourceAzureRMAppServicePlan_basicWindowsContainer(t *testing.T) {
dataSourceName := "data.azurerm_app_service_plan.test"
rInt := tf.AccRandTimeInt()
Expand Down Expand Up @@ -143,6 +166,41 @@ data "azurerm_app_service_plan" "test" {
`, rInt, location, rInt)
}

func testAccDataSourceAppServicePlan_premiumSKU(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
kind = "elastic"
maximum_elastic_worker_count = 20
sku {
tier = "ElasticPremium"
size = "EP1"
}
properties {
per_site_scaling = true
}
tags = {
environment = "Test"
}
}
data "azurerm_app_service_plan" "test" {
name = "${azurerm_app_service_plan.test.name}"
resource_group_name = "${azurerm_app_service_plan.test.resource_group_name}"
}
`, rInt, location, rInt)
}

func testAccDataSourceAppServicePlan_basicWindowsContainer(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand Down
15 changes: 15 additions & 0 deletions azurerm/resource_arm_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func resourceArmAppServicePlan() *schema.Resource {
},
},

/// AppServicePlanProperties
"app_service_environment_id": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -140,6 +141,12 @@ func resourceArmAppServicePlan() *schema.Resource {
ConflictsWith: []string{"properties.0.reserved"},
},

"maximum_elastic_worker_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"maximum_number_of_workers": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -216,6 +223,10 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac
}
}

if v, exists := d.GetOkExists("maximum_elastic_worker_count"); exists {
appServicePlan.AppServicePlanProperties.MaximumElasticWorkerCount = utils.Int32(int32(v.(int)))
}

if reservedExists {
appServicePlan.AppServicePlanProperties.Reserved = utils.Bool(reserved.(bool))
}
Expand Down Expand Up @@ -288,6 +299,10 @@ func resourceArmAppServicePlanRead(d *schema.ResourceData, meta interface{}) err
d.Set("maximum_number_of_workers", int(*props.MaximumNumberOfWorkers))
}

if props.MaximumElasticWorkerCount != nil {
d.Set("maximum_elastic_worker_count", int(*props.MaximumElasticWorkerCount))
}

d.Set("per_site_scaling", props.PerSiteScaling)
d.Set("reserved", props.Reserved)
}
Expand Down
3 changes: 3 additions & 0 deletions azurerm/resource_arm_app_service_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ func TestAccAzureRMAppServicePlan_premiumConsumptionPlan(t *testing.T) {
testCheckAzureRMAppServicePlanExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "ElasticPremium"),
resource.TestCheckResourceAttr(resourceName, "sku.0.size", "EP1"),
resource.TestCheckResourceAttr(resourceName, "maximum_elastic_worker_count", "20"),
),
},
},
Expand Down Expand Up @@ -616,6 +617,8 @@ resource "azurerm_app_service_plan" "test" {
location = "${azurerm_resource_group.test.location}"
kind = "elastic"
maximum_elastic_worker_count = 20
sku {
tier = "ElasticPremium"
size = "EP1"
Expand Down
3 changes: 2 additions & 1 deletion website/docs/d/app_service_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ output "app_service_plan_id" {

* `tags` - A mapping of tags assigned to the resource.

* `maximum_number_of_workers` - The maximum number of workers supported with the App Service Plan's sku.
* `maximum_elastic_worker_count` - The maximum number of total workers allowed for this ElasticScaleEnabled App Service Plan.

* `is_xenon` - A flag that indicates if it's a xenon plan (support for Windows Container)

* `maximum_number_of_workers` - The maximum number of workers supported with the App Service Plan's sku.
---

A `sku` block supports the following:
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/app_service_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ The following arguments are supported:

* `kind` - (Optional) The kind of the App Service Plan to create. Possible values are `Windows` (also available as `App`), `Linux`, `elastic` (for Premium Consumption) and `FunctionApp` (for a Consumption Plan). Defaults to `Windows`. Changing this forces a new resource to be created.

* `maximum_elastic_worker_count` - The maximum number of total workers allowed for this ElasticScaleEnabled App Service Plan.

~> **NOTE:** When creating a `Linux` App Service Plan, the `reserved` field must be set to `true`.

* `sku` - (Required) A `sku` block as documented below.
Expand All @@ -130,7 +132,6 @@ The following arguments are supported:
* `capacity` - (Optional) Specifies the number of workers associated with this App Service Plan.



## Attributes Reference

The following attributes are exported:
Expand Down

0 comments on commit 0f66fd7

Please sign in to comment.