Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/azurerm: Add maximum_elastic_worker_count to app_service_plan #3547

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": {
stack72 marked this conversation as resolved.
Show resolved Hide resolved
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
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 @@ -118,6 +118,7 @@ func resourceArmAppServicePlan() *schema.Resource {
},
},

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

"maximum_elastic_worker_count": {
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntAtLeast(0),
},

"maximum_number_of_workers": {
stack72 marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -216,6 +224,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 +300,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.
stack72 marked this conversation as resolved.
Show resolved Hide resolved

* `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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to not break the formatting, can we make this:

Suggested change
* `maximum_number_of_workers` - The maximum number of workers supported with the App Service Plan's sku.
* `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