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 - support for Linux App Services #332

Merged
merged 2 commits into from
Sep 13, 2017
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
16 changes: 8 additions & 8 deletions azurerm/import_arm_app_service_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMAppServicePlan_importBasic(t *testing.T) {
func TestAccAzureRMAppServicePlan_importBasicWindows(t *testing.T) {
resourceName := "azurerm_app_service_plan.test"

ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_basic(ri, testLocation())
config := testAccAzureRMAppServicePlan_basicWindows(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -30,11 +30,11 @@ func TestAccAzureRMAppServicePlan_importBasic(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_importStandard(t *testing.T) {
func TestAccAzureRMAppServicePlan_importWindowsStandard(t *testing.T) {
resourceName := "azurerm_app_service_plan.test"

ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_standard(ri, testLocation())
config := testAccAzureRMAppServicePlan_standardWindows(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -53,11 +53,11 @@ func TestAccAzureRMAppServicePlan_importStandard(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_importPremium(t *testing.T) {
func TestAccAzureRMAppServicePlan_importPremiumWindows(t *testing.T) {
resourceName := "azurerm_app_service_plan.test"

ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_premium(ri, testLocation())
config := testAccAzureRMAppServicePlan_premiumWindows(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -76,11 +76,11 @@ func TestAccAzureRMAppServicePlan_importPremium(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_importComplete(t *testing.T) {
func TestAccAzureRMAppServicePlan_importCompleteWindows(t *testing.T) {
resourceName := "azurerm_app_service_plan.test"

ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_complete(ri, testLocation())
config := testAccAzureRMAppServicePlan_completeWindows(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
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 @@ -6,6 +6,7 @@ import (

"github.com/Azure/azure-sdk-for-go/arm/web"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -34,6 +35,18 @@ func resourceArmAppServicePlan() *schema.Resource {

"location": locationSchema(),

"kind": {
Type: schema.TypeString,
Optional: true,
Default: "Windows",
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"Linux",
"Windows",
}, true),
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},

"sku": {
Type: schema.TypeList,
Required: true,
Expand Down Expand Up @@ -96,6 +109,7 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac
resGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)
location := d.Get("location").(string)
kind := d.Get("kind").(string)
tags := d.Get("tags").(map[string]interface{})

sku := expandAzureRmAppServicePlanSku(d)
Expand All @@ -104,6 +118,7 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac
appServicePlan := web.AppServicePlan{
Location: &location,
AppServicePlanProperties: properties,
Kind: &kind,
Tags: expandTags(tags),
Sku: &sku,
}
Expand Down Expand Up @@ -153,6 +168,7 @@ func resourceArmAppServicePlanRead(d *schema.ResourceData, meta interface{}) err
d.Set("name", name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("kind", resp.Kind)

if props := resp.AppServicePlanProperties; props != nil {
d.Set("properties", flattenAppServiceProperties(props))
Expand Down
73 changes: 57 additions & 16 deletions azurerm/resource_arm_app_service_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func TestAccAzureRMAppServicePlan_basic(t *testing.T) {
func TestAccAzureRMAppServicePlan_basicWindows(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_basic(ri, testLocation())
config := testAccAzureRMAppServicePlan_basicWindows(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -29,9 +29,9 @@ func TestAccAzureRMAppServicePlan_basic(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_standard(t *testing.T) {
func TestAccAzureRMAppServicePlan_basicLinux(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_standard(ri, testLocation())
config := testAccAzureRMAppServicePlan_basicLinux(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -48,9 +48,9 @@ func TestAccAzureRMAppServicePlan_standard(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_premium(t *testing.T) {
func TestAccAzureRMAppServicePlan_standardWindows(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_premium(ri, testLocation())
config := testAccAzureRMAppServicePlan_standardWindows(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -67,12 +67,31 @@ func TestAccAzureRMAppServicePlan_premium(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_premiumUpdated(t *testing.T) {
func TestAccAzureRMAppServicePlan_premiumWindows(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_premiumWindows(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAppServicePlanDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServicePlanExists("azurerm_app_service_plan.test"),
),
},
},
})
}

func TestAccAzureRMAppServicePlan_premiumWindowsUpdated(t *testing.T) {
resourceName := "azurerm_app_service_plan.test"
ri := acctest.RandInt()
location := testLocation()
config := testAccAzureRMAppServicePlan_premium(ri, location)
updatedConfig := testAccAzureRMAppServicePlan_premiumUpdated(ri, location)
config := testAccAzureRMAppServicePlan_premiumWindows(ri, location)
updatedConfig := testAccAzureRMAppServicePlan_premiumWindowsUpdated(ri, location)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -97,10 +116,10 @@ func TestAccAzureRMAppServicePlan_premiumUpdated(t *testing.T) {
})
}

func TestAccAzureRMAppServicePlan_complete(t *testing.T) {
func TestAccAzureRMAppServicePlan_completeWindows(t *testing.T) {
resourceName := "azurerm_app_service_plan.test"
ri := acctest.RandInt()
config := testAccAzureRMAppServicePlan_complete(ri, testLocation())
config := testAccAzureRMAppServicePlan_completeWindows(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -175,7 +194,27 @@ func testCheckAzureRMAppServicePlanExists(name string) resource.TestCheckFunc {
}
}

func testAccAzureRMAppServicePlan_basic(rInt int, location string) string {
func testAccAzureRMAppServicePlan_basicWindows(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}"

sku {
tier = "Basic"
size = "B1"
}
}
`, rInt, location, rInt)
}

func testAccAzureRMAppServicePlan_basicLinux(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -186,6 +225,7 @@ resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
kind = "Linux"

sku {
tier = "Basic"
Expand All @@ -195,7 +235,7 @@ resource "azurerm_app_service_plan" "test" {
`, rInt, location, rInt)
}

func testAccAzureRMAppServicePlan_standard(rInt int, location string) string {
func testAccAzureRMAppServicePlan_standardWindows(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -215,7 +255,7 @@ resource "azurerm_app_service_plan" "test" {
`, rInt, location, rInt)
}

func testAccAzureRMAppServicePlan_premium(rInt int, location string) string {
func testAccAzureRMAppServicePlan_premiumWindows(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -235,7 +275,7 @@ resource "azurerm_app_service_plan" "test" {
`, rInt, location, rInt)
}

func testAccAzureRMAppServicePlan_premiumUpdated(rInt int, location string) string {
func testAccAzureRMAppServicePlan_premiumWindowsUpdated(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -256,7 +296,7 @@ resource "azurerm_app_service_plan" "test" {
`, rInt, location, rInt)
}

func testAccAzureRMAppServicePlan_complete(rInt int, location string) string {
func testAccAzureRMAppServicePlan_completeWindows(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -267,6 +307,7 @@ resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
kind = "Windows"

sku {
tier = "Standard"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/app_service_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ 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.

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

* `properties` - (Optional) A `properties` block as documented below.
Expand Down