Skip to content

Commit

Permalink
Merge pull request #849 from terraform-providers/app-service-plan-dat…
Browse files Browse the repository at this point in the history
…a-source-crash

d/App Service Plan: handling a 404 not being returned as an error
  • Loading branch information
tombuildsstuff authored Feb 16, 2018
2 parents 1f9b236 + 8872929 commit 98a4834
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions azurerm/data_source_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,24 @@ func dataSourceAppServicePlanRead(d *schema.ResourceData, meta interface{}) erro
ctx := meta.(*ArmClient).StopContext
resp, err := client.Get(ctx, resourceGroup, name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
d.SetId("")
return nil
}

return fmt.Errorf("Error making Read request on App Service Plan %q (Resource Group %q): %+v", name, resourceGroup, err)
}

if utils.ResponseWasNotFound(resp.Response) {
d.SetId("")
return nil
}

d.SetId(*resp.ID)

d.Set("name", name)
d.Set("resource_group_name", resourceGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("kind", resp.Kind)

if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if props := resp.AppServicePlanProperties; props != nil {
d.Set("properties", flattenAppServiceProperties(props))

Expand Down

0 comments on commit 98a4834

Please sign in to comment.