diff --git a/internal/provider/resource_cname_record.go b/internal/provider/resource_cname_record.go index 5802d1c..c83e83b 100644 --- a/internal/provider/resource_cname_record.go +++ b/internal/provider/resource_cname_record.go @@ -64,6 +64,11 @@ func resourceCNAMERecordRead(ctx context.Context, d *schema.ResourceData, meta i record, err := client.GetCNAMERecord(ctx, d.Id()) if err != nil { + if _, ok := err.(*pihole.NotFoundError); ok { + d.SetId("") + return nil + } + return diag.FromErr(err) } diff --git a/internal/provider/resource_dns_record.go b/internal/provider/resource_dns_record.go index e9dbdfb..426b491 100644 --- a/internal/provider/resource_dns_record.go +++ b/internal/provider/resource_dns_record.go @@ -63,6 +63,11 @@ func resourceDNSRecordRead(ctx context.Context, d *schema.ResourceData, meta int record, err := client.GetDNSRecord(ctx, d.Id()) if err != nil { + if _, ok := err.(*pihole.NotFoundError); ok { + d.SetId("") + return nil + } + return diag.FromErr(err) } diff --git a/internal/provider/resource_group.go b/internal/provider/resource_group.go index f7b300e..1e33987 100644 --- a/internal/provider/resource_group.go +++ b/internal/provider/resource_group.go @@ -98,6 +98,11 @@ func resourceGroupRead(ctx context.Context, d *schema.ResourceData, meta interfa group, err := client.GetGroup(ctx, name) if err != nil { + if _, ok := err.(*pihole.NotFoundError); ok { + d.SetId("") + return nil + } + return diag.FromErr(err) }