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

google_project skip_delete = true argument remove project from tfstate but shouldn't #4138

Closed
kelu27 opened this issue Jul 31, 2019 · 3 comments
Labels

Comments

@kelu27
Copy link

kelu27 commented Jul 31, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

Terraform v0.12.5

  • provider.google v2.11.0
  • provider.google-beta v2.11.0

Affected Resource(s)

  • google_project

Terraform Configuration Files

resource "google_project" "project" {

  name                 = "dzr-test-dev"
  project_id          = "dzr-test-dev"
  folder_id            = "01234567890"
  billing_account  =  "01234567890"
  auto_create_network = true
  skip_delete         = true
}

Debug Output

Panic Output

Expected Behavior

After destroying a project with the skip_delete = true argument, I wanted it to be kept in the state file like this:

  "resources": [
    {
      "module": "module.project",
      "mode": "managed",
      "type": "google_project",
      "name": "project",
      "provider": "provider.google",
      "instances": [
        {
          "schema_version": 1,
          "attributes": {
            "app_engine": [],
            "auto_create_network": true,
            "billing_account": "012345-123456-123456",
            "folder_id": "01234567890",
            "id": "dzr-test-dev",
            "name": "dzr-test-dev",
            "number": "01234567890",
            "org_id": "01234567890",
            "policy_data": null,
            "policy_etag": null,
            "project_id": "dzr-test-dev",
            "skip_delete": true
          },
          "private": "eblublurandom"
        }
      ]
    }

Actual Behavior

The project is deleted in the terraform.tfstate file, but it's not deleted in Gcloud thanks to skip_delete = true argument.
I can't add new resources with terraform because the project is already created but the tfstate file is updated as if the project is deleted.
I need to re-import it manually if I want to bypass this behavior.

I suppose that the google_project part of the tfstate file don't need to be updated with the command terraform destroy and the skip_delete = true argument in the google_project resource.

Steps to Reproduce

  1. terraform apply
  2. terraform destroy

Important Factoids

References

  • #0000
@ghost ghost added the bug label Jul 31, 2019
@kelu27 kelu27 changed the title google_project state don't correspond to the actual state. google_project skip_delete = true remove project from tfstate but shouldn't Jul 31, 2019
@kelu27 kelu27 changed the title google_project skip_delete = true remove project from tfstate but shouldn't google_project skip_delete = true argument remove project from tfstate but shouldn't Jul 31, 2019
@paddycarver paddycarver self-assigned this Aug 1, 2019
@paddycarver
Copy link
Contributor

Hi @kelu27! I think there's been some confusion here; skip_delete means that Terraform will never delete the project from the API, not that it won't be removed from Terraform. As the documentation says:

If true, the Terraform resource can be deleted without deleting the Project via the Google API.

It sounds like you expected it to keep the project in the Terraform state file. You can use the lifecycle.prevent_destroy to have Terraform throw an error when the project is attempted to be deleted. Unfortunately, there is no Terraform behavior that would allow you to delete a project and have it in Terraform's state file.

Can you tell me more about why that's something you're looking for the ability to do?

@paddycarver paddycarver removed their assignment Mar 9, 2020
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Oct 23, 2020
Co-authored-by: Cameron Thornton <[email protected]>
Co-authored-by: angie pinilla <[email protected]>

Co-authored-by: angie pinilla <[email protected]>
Signed-off-by: Modular Magician <[email protected]>
modular-magician added a commit that referenced this issue Oct 23, 2020
Co-authored-by: Cameron Thornton <[email protected]>
Co-authored-by: angie pinilla <[email protected]>

Co-authored-by: angie pinilla <[email protected]>
Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: angie pinilla <[email protected]>
@github-actions github-actions bot added forward/review In review; remove label to forward service/cloudresourcemanager-crm labels Sep 27, 2023
@edwardmedia
Copy link
Contributor

edwardmedia commented Oct 3, 2023

closing based on no response

Copy link

github-actions bot commented Nov 3, 2023

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants