Skip to content

Commit

Permalink
Merge pull request #2497 from cloudflare/remove-cert-from-state-after…
Browse files Browse the repository at this point in the history
…-deletion
  • Loading branch information
jacobbednarz authored Jun 5, 2023
2 parents 85f9cc7 + dc73d74 commit 7d8d8d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/2497.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/cloudflare_certificate_pack: handle UI deletion scenarios for HTTP 404s and `status = "deleted"` responses
```
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ func resourceCloudflareCertificatePackRead(ctx context.Context, d *schema.Resour

certificatePack, err := client.CertificatePack(ctx, zoneID, d.Id())
if err != nil {
var notFoundError *cloudflare.NotFoundError
if errors.As(err, &notFoundError) || certificatePack.Status == "deleted" {
tflog.Warn(ctx, fmt.Sprintf("removing certificate pack from state because it is not found in the API"))
d.SetId("")
return nil
}
return diag.FromErr(errors.Wrap(err, "failed to fetch certificate pack"))
}

Expand Down

0 comments on commit 7d8d8d8

Please sign in to comment.