-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Remove project if it has been deleted from outside of Terraform #466
Conversation
@@ -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" { |
There was a problem hiding this comment.
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"
No problems here. |
google/resource_google_project.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Added.
Merge 2.1.0 release into master
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! |
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