Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove project if it has been deleted from outside of Terraform #466

Merged

Conversation

rosbo
Copy link
Contributor

@rosbo rosbo commented Sep 26, 2017

Fixes #451

If everybody agree with this behavior, I will update the google_folder resource to follow the same pattern in a separate PR.

cc/ @ewbankkit

@rosbo rosbo requested a review from selmanj September 26, 2017 21:51
@@ -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" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

LifecycleState has the following possible values:

  • "ACTIVE"
  • "DELETE_REQUESTED"
  • "DELETE_IN_PROGRESS"

@ewbankkit
Copy link
Contributor

No problems here.

@@ -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 the project is not active.", pid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor; printing the state as well might be useful for debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Added.

@rosbo rosbo merged commit ace5dff into hashicorp:master Sep 26, 2017
negz pushed a commit to negz/terraform-provider-google that referenced this pull request Oct 17, 2017
luis-silva pushed a commit to luis-silva/terraform-provider-google that referenced this pull request May 21, 2019
@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google_project resource in DELETE_REQUESTED state causes terraform plan error
3 participants