From eadab9b721db3f12e68d159ae42dca5517d46319 Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Thu, 1 Aug 2019 10:36:04 -0700 Subject: [PATCH] Bug Fix: `azurerm_app_service_plan` - workaround for missing error on 404 #3990 --- azurerm/resource_arm_app_service_plan.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/azurerm/resource_arm_app_service_plan.go b/azurerm/resource_arm_app_service_plan.go index 2adafa682ca1..a6655d2eb59c 100644 --- a/azurerm/resource_arm_app_service_plan.go +++ b/azurerm/resource_arm_app_service_plan.go @@ -279,6 +279,14 @@ func resourceArmAppServicePlanRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error making Read request on App Service Plan %q (Resource Group %q): %+v", name, resourceGroup, err) } + // A 404 doesn't error from the app service plan sdk so we'll add this check here to catch resource not found responses + // TODO This block can be removed if https://github.com/Azure/azure-sdk-for-go/issues/5407 gets addressed. + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[DEBUG] App Service Plan %q was not found in Resource Group %q - removnig from state!", name, resourceGroup) + d.SetId("") + return nil + } + d.Set("name", name) d.Set("resource_group_name", resourceGroup) if location := resp.Location; location != nil {