From baccee0b56fe89447d2abacc158aa38ff51da6f0 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Fri, 3 Nov 2023 13:52:16 -0400 Subject: [PATCH] load balancers: ignore 404 on delete. --- digitalocean/loadbalancer/resource_loadbalancer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/digitalocean/loadbalancer/resource_loadbalancer.go b/digitalocean/loadbalancer/resource_loadbalancer.go index 446b2bc4e..218a82d76 100644 --- a/digitalocean/loadbalancer/resource_loadbalancer.go +++ b/digitalocean/loadbalancer/resource_loadbalancer.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log" + "net/http" "strings" "time" @@ -655,8 +656,13 @@ func resourceDigitalOceanLoadbalancerDelete(ctx context.Context, d *schema.Resou client := meta.(*config.CombinedConfig).GodoClient() log.Printf("[INFO] Deleting Load Balancer: %s", d.Id()) - _, err := client.LoadBalancers.Delete(context.Background(), d.Id()) + resp, err := client.LoadBalancers.Delete(context.Background(), d.Id()) if err != nil { + if resp != nil && resp.StatusCode == http.StatusNotFound { + d.SetId("") + return nil + } + return diag.Errorf("Error deleting Load Balancer: %s", err) }