Skip to content

Commit

Permalink
fix resourceOpsGenieServiceIncidentRuleRead to detect deletion from UI (
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunrajpal authored Jul 27, 2023
1 parent 744e96e commit f2fd65f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions opsgenie/resource_opsgenie_service_incident_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,20 @@ func resourceOpsGenieServiceIncidentRuleRead(d *schema.ResourceData, meta interf
}
}

incidentRuleFound := false
for _, v := range incident_rule_res.IncidentRule {
if v.Id == incident_rule_id {
d.Set("service_id", service_id)
d.Set("incident_rule", flattenOpsGenieServiceIncidentRules(v))
incidentRuleFound = true
}
}

if !incidentRuleFound {
log.Printf("[WARN] Incident Rule with id: %s not found", d.Id())
d.SetId("")
}

return nil
}

Expand Down

0 comments on commit f2fd65f

Please sign in to comment.