Handle `google_storage_bucket_object` not being found (#14203)

Mark the resource as no longer available.
This commit is contained in:
Daniel Schierbeck 2017-05-04 19:57:49 +02:00 committed by Paul Stack
parent 9f7c5394f1
commit 7a2f002f56
1 changed files with 8 additions and 0 deletions

View File

@ -151,6 +151,14 @@ func resourceStorageBucketObjectDelete(d *schema.ResourceData, meta interface{})
err := DeleteCall.Do() err := DeleteCall.Do()
if err != nil { if err != nil {
if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 {
log.Printf("[WARN] Removing Bucket Object %q because it's gone", name)
// The resource doesn't exist anymore
d.SetId("")
return nil
}
return fmt.Errorf("Error deleting contents of object %s: %s", name, err) return fmt.Errorf("Error deleting contents of object %s: %s", name, err)
} }