Skip to content

Commit

Permalink
Set ID to nothing if the policy is gone on the API (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbytables authored Oct 24, 2024
1 parent 6c348e9 commit 85a478a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.13.1

BUG FIXES:
* Fixes a bug where escalation policy resources were not being removed from state if deleted outside of Terraform

## 0.13.0

ENHANCEMENTS:
Expand Down
10 changes: 10 additions & 0 deletions provider/escalation_policy_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package provider

import (
"context"
"errors"
"fmt"

"github.com/davecgh/go-spew/spew"
"github.com/firehydrant/terraform-provider-firehydrant/firehydrant"
Expand Down Expand Up @@ -106,6 +108,14 @@ func readResourceFireHydrantEscalationPolicy(ctx context.Context, d *schema.Reso

escalationPolicy, err := firehydrantAPIClient.EscalationPolicies().Get(ctx, teamID, id)
if err != nil {
if errors.Is(err, firehydrant.ErrorNotFound) {
tflog.Debug(ctx, fmt.Sprintf("Escalation Policy %s no longer exists", id), map[string]interface{}{
"id": id,
})
d.SetId("")
return nil
}

return diag.Errorf("Error reading escalation policy %s: %v", id, err)
}

Expand Down

0 comments on commit 85a478a

Please sign in to comment.