Closed ewbankkit closed 6 years ago
Hi Kit,
I am curious about what behavior you expect when the project is in DELETE_REQUESTED state?
A) Delete from tf.state (that's what calling handleNotFoundError
like you suggested would do) and recreate a brand new project.
B) Call undelete on the project making it ACTIVE
again.
If the project is deleted via terraform destroy
then the resource will be removed from the corresponding state file and we shouldn't get into this situation on the next terraform plan
(we'd see a new project was going to be created). So we should only get into this situation if the project is deleted outside of Terraform.
In this case I would say go with B) - re-activate the project; If the user really wants to delete the project she will have to remove the corresponding resource from the code AND the state file (else if it's not removed from the state file the next terraform plan
will get the same error).
However, a case can be made for A) also 😄.
BTW, it looks like folders can also be undeleted and that resource has lifecycle_state
attribute. Consistency of behavior will be important I think.
I can think of no prior art here for other resources/cloud providers I know except for some similarity to re-creating the AWS default VPC for a region - https://github.com/terraform-providers/terraform-provider-aws/pull/1400.
Agreed, folders and projects should behave the same way for this.
I am also leaning towards B).
@danawillow @paddycarver @selmanj Any thoughts before I update our project and folder resources to handle this case?
Yup, same.
I think we should handle DELETE_REQUESTED as if it were actually deleted- so a plan would show it as being created, and apply would un-delete it. It's a bit tricky because if it has any properties (I guess just billing account right now) that change, they'd have to be updated as well alongside the undelete.
I am hesitant about using an undelete; from the docs:
Project owners can restore a terminated project within the 30-day waiting period that starts when the project is shut down. Restoring a project returns it to the state it was in prior to being shut down.
As a user, it would be surprising to me if I deleted a project, recreated it, and then all the previous state was restored (more specifically, all the resources associated with the project get revived). That works different from every other resource in terraform.
@selmanj you convinced me. undelete cloud be quite surprising. If they deleted it from the console by mistake, they can undelete it from there.
I will handle the not found error properly and this will trigger a new project creation.
(Chiming in late that support for undelete would be very cool in certain situations, but I too believe it would lead to confusing and unexpected edge cases and it would probably be better to delete from state. So what y'all said, just agreeing. :) )
Thanks to @ewbankkit . Well, the restoring terminated project in GCP worked for me. We are facing the same issue while creating the new project through Jenkins using terraform.
Hi @AbhinayGupta741, this issue has been closed for over two years so I think most of us have lost context as this point. If you're experiencing problems still, could you please open a new one in the tracker and fill out the template completely? Thanks!
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 👉 hashibot-feedback@hashicorp.com. Thanks!
I successfully create a project via Terraform:
and then shut down the project in the GCP console. The project transitions to
DELETE_REQUESTED
state. I then runterraform plan
and get an error:Running with logging on: