Skip to content
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
Next Next commit
adding support for App Service Plans being Dynamic/Consumption Plans
  • Loading branch information
tombuildsstuff committed Mar 15, 2018
commit 9d6b7fe9c9ccdcca61b4dd8fa006c35f3fc7ecf2
1 change: 1 addition & 0 deletions azurerm/resource_arm_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func resourceArmAppServicePlan() *schema.Resource {
Default: "Windows",
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"FunctionApp",
"Linux",
"Windows",
}, true),
Expand Down
43 changes: 43 additions & 0 deletions azurerm/resource_arm_app_service_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,28 @@ func TestAccAzureRMAppServicePlan_completeWindows(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_consumptionPlan(t *testing.T) {
resourceName := "azurerm_app_service_plan.test"
ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_consumptionPlan(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAppServicePlanDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServicePlanExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "Dynamic"),
resource.TestCheckResourceAttr(resourceName, "sku.0.size", "Y1"),
),
},
},
})
}

func testCheckAzureRMAppServicePlanDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*ArmClient).appServicePlansClient

Expand Down Expand Up @@ -365,3 +387,24 @@ resource "azurerm_app_service_plan" "test" {
}
`, rInt, location, rInt)
}

func testAccAzureRMAppServicePlan_consumptionPlan(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"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
kind = "FunctionApp"

sku {
tier = "Dynamic"
size = "Y1"
}
}
`, rInt, location, rInt)
}
27 changes: 24 additions & 3 deletions website/docs/r/app_service_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: |-

Create an App Service Plan component.

## Example Usage
## Example Usage (Dedicated)

```hcl
resource "azurerm_resource_group" "test" {
Expand All @@ -20,7 +20,7 @@ resource "azurerm_resource_group" "test" {

resource "azurerm_app_service_plan" "test" {
name = "api-appserviceplan-pro"
location = "West Europe"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"

sku {
Expand All @@ -30,6 +30,27 @@ resource "azurerm_app_service_plan" "test" {
}
```

## Example Usage (Shared / Consumption Plan)

```hcl
resource "azurerm_resource_group" "test" {
name = "api-rg-pro"
location = "West Europe"
}

resource "azurerm_app_service_plan" "test" {
name = "api-appserviceplan-pro"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
kind = "FunctionApp"

sku {
tier = "Dynamic"
size = "Y1"
}
}
```

## Argument Reference

The following arguments are supported:
Expand All @@ -40,7 +61,7 @@ The following arguments are supported:

* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

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

* `sku` - (Required) A `sku` block as documented below.

Expand Down