Skip to content

Commit

Permalink
Remove project if it has been deleted from outside of Terraform (hash…
Browse files Browse the repository at this point in the history
  • Loading branch information
rosbo authored Sep 26, 2017
1 parent 54638cc commit 4b0e34a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions google/resource_google_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ func resourceGoogleProjectRead(d *schema.ResourceData, meta interface{}) error {
return handleNotFoundError(err, d, fmt.Sprintf("Project %q", pid))
}

// If the project has been deleted from outside Terraform, remove it from state file.
if p.LifecycleState != "ACTIVE" {
log.Printf("[WARN] Removing project '%s' because its state is '%s' (requires 'ACTIVE').", pid, p.LifecycleState)
d.SetId("")
return nil
}

d.Set("project_id", pid)
d.Set("number", strconv.FormatInt(int64(p.ProjectNumber), 10))
d.Set("name", p.Name)
Expand Down

0 comments on commit 4b0e34a

Please sign in to comment.