Skip to content

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

@kelu27

Description

@kelu27

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions