Skip to content

Commit

Permalink
Fix: Remove resource from statefile for pending_reclamation state
Browse files Browse the repository at this point in the history
  • Loading branch information
kavya498 authored and hkantare committed May 20, 2021
1 parent 60f65da commit eb1807e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ibm/resource_ibm_cis.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ func resourceIBMCISInstanceExists(d *schema.ResourceData, meta interface{}) (boo
}
return false, fmt.Errorf("Error communicating with the API: %s %s", err, response)
}
if strings.Contains(*instance.State, "removed") {
log.Printf("[WARN] Removing instance from state because it's in removed state")
if instance != nil && (strings.Contains(*instance.State, "removed") || strings.Contains(*instance.State, cisInstanceReclamation)) {
log.Printf("[WARN] Removing instance from state because it's in removed or pending_reclamation state")
d.SetId("")
return false, nil
}
Expand Down
4 changes: 2 additions & 2 deletions ibm/resource_ibm_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -1818,8 +1818,8 @@ func resourceIBMDatabaseInstanceExists(d *schema.ResourceData, meta interface{})
}
return false, fmt.Errorf("Error communicating with the API: %s %s", err, response)
}
if strings.Contains(*instance.State, "removed") {
log.Printf("[WARN] Removing instance from state because it's in removed state")
if instance != nil && (strings.Contains(*instance.State, "removed") || strings.Contains(*instance.State, databaseInstanceReclamation)) {
log.Printf("[WARN] Removing instance from state because it's in removed or pending_reclamation state")
d.SetId("")
return false, nil
}
Expand Down
5 changes: 5 additions & 0 deletions ibm/resource_ibm_resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,11 @@ func resourceIBMResourceInstanceExists(d *schema.ResourceData, meta interface{})
}
return false, fmt.Errorf("Error communicating with the API: %s with resp code: %s", err, resp)
}
if instance != nil && (strings.Contains(*instance.State, "removed") || strings.Contains(*instance.State, rsInstanceReclamation)) {
log.Printf("[WARN] Removing instance from state because it's in removed or pending_reclamation state")
d.SetId("")
return false, nil
}

return *instance.ID == instanceID, nil
}
Expand Down

0 comments on commit eb1807e

Please sign in to comment.