From bcf010a9581fc5a91cbde7e8d7c8d41b45b58777 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 12 Aug 2019 12:25:48 -0700 Subject: [PATCH] Catch 404s when deleting default networks. (#4137) Signed-off-by: Modular Magician --- google/resource_google_project.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/google/resource_google_project.go b/google/resource_google_project.go index bd70cf43baa..7ef8bc854ee 100644 --- a/google/resource_google_project.go +++ b/google/resource_google_project.go @@ -274,7 +274,11 @@ func resourceGoogleProjectCreate(d *schema.ResourceData, meta interface{}) error } if err = forceDeleteComputeNetwork(project.ProjectId, "default", config); err != nil { - return fmt.Errorf("Error deleting default network in project %s: %s", project.ProjectId, err) + if isGoogleApiErrorWithCode(err, 404) { + log.Printf("[DEBUG] Default network not found for project %q, no need to delete it", project.ProjectId) + } else { + return fmt.Errorf("Error deleting default network in project %s: %s", project.ProjectId, err) + } } } return nil