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

azurerm_app_service_plan - update the relation between kind and reserved #7943

Merged
merged 3 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac
return fmt.Errorf("`reserved` has to be set to true when kind is set to `Linux`")
}

if !strings.EqualFold(kind, "Linux") && reserved {
return fmt.Errorf("`reserved` has to be set to false when kind isn't set to `Linux`")
if strings.EqualFold(kind, "Windows") && reserved {
return fmt.Errorf("`reserved` has to be set to false when kind is set to `Windows`")
}

if v := d.Get("maximum_elastic_worker_count").(int); v > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,25 @@ func TestAccAzureRMAppServicePlan_consumptionPlan(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_linuxConsumptionPlan(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMAppServicePlanDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAppServicePlan_linuxConsumptionPlan(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServicePlanExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}

func TestAccAzureRMAppServicePlan_premiumConsumptionPlan(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test")

Expand Down Expand Up @@ -560,6 +579,32 @@ resource "azurerm_app_service_plan" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func testAccAzureRMAppServicePlan_linuxConsumptionPlan(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
kind = "FunctionApp"
reserved = true

sku {
tier = "Dynamic"
size = "Y1"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func testAccAzureRMAppServicePlan_premiumConsumptionPlan(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/app_service_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ 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.

~> **NOTE:** When creating a `Linux` App Service Plan, the `reserved` field must be set to `true`, and when creating other kinds of App Service Plan, the `reserved` field must be set to `false`.
~> **NOTE:** When creating a `Linux` App Service Plan, the `reserved` field must be set to `true`, and when creating a `Windows`/`app` App Service Plan the `reserved` field must be set to `false`.

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

Expand Down