Skip to content

Commit

Permalink
Merge pull request #3048 from terraform-providers/f/moving-app-service
Browse files Browse the repository at this point in the history
r/app_service: support for migrating between App Service Plans
  • Loading branch information
tombuildsstuff authored Mar 15, 2019
2 parents de8c019 + 9b95a8a commit 69a5367
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
1 change: 0 additions & 1 deletion azurerm/resource_arm_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func resourceArmAppService() *schema.Resource {
"app_service_plan_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"site_config": azure.SchemaAppServiceSiteConfig(),
Expand Down
64 changes: 64 additions & 0 deletions azurerm/resource_arm_app_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,32 @@ func TestAccAzureRMAppService_requiresImport(t *testing.T) {
})
}

func TestAccAzureRMAppService_movingAppService(t *testing.T) {
resourceName := "azurerm_app_service.test"
ri := tf.AccRandTimeInt()
location := testLocation()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAppServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAppService_basic(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(resourceName),
),
},
{
Config: testAccAzureRMAppService_moved(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(resourceName),
),
},
},
})
}

func TestAccAzureRMAppService_freeTier(t *testing.T) {
resourceName := "azurerm_app_service.test"
ri := tf.AccRandTimeInt()
Expand Down Expand Up @@ -1310,6 +1336,44 @@ resource "azurerm_app_service" "test" {
`, rInt, location, rInt, rInt)
}

func testAccAzureRMAppService_moved(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 = "Standard"
size = "S1"
}
}
resource "azurerm_app_service_plan" "other" {
name = "acctestASP2-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "acctestAS-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
app_service_plan_id = "${azurerm_app_service_plan.other.id}"
}
`, rInt, location, rInt, rInt, rInt)
}

func testAccAzureRMAppService_sharedTier(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,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.

* `app_service_plan_id` - (Required) The ID of the App Service Plan within which to create this App Service. Changing this forces a new resource to be created.
* `app_service_plan_id` - (Required) The ID of the App Service Plan within which to create this App Service.

* `app_settings` - (Optional) A key-value pair of App Settings.

Expand Down

0 comments on commit 69a5367

Please sign in to comment.