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

leftover module in state that should have been removed #23821

Closed
andrey-dubnik opened this issue Jan 9, 2020 · 1 comment · Fixed by #23822
Closed

leftover module in state that should have been removed #23821

andrey-dubnik opened this issue Jan 9, 2020 · 1 comment · Fixed by #23822

Comments

@andrey-dubnik
Copy link

Terraform version: 0.12.19

Problem
The problem is when we do destroy via plan -destroy resources list is not getting completely cleaned-up leaving resources in the state file. The issue does not manifest itself until there is a dependency on the resource and destroy (via plan)>apply was called. In our case we did plan -destroy with subsequent apply (sandbox environment) which resulted in error because we had output of the module with depends_on condition on the resource created. Because resource which had depends_on also had count it was present in the state file after the original destroy hence module considered this resource as already created for the depends_on condition and our output logic was broken so did our infrastructure pipeline.

Expected behaviour
both plan -destroy and destroy should leave no resources in the state file.

How to reproduce

main.tf

data "null_data_source" "values" {
  count = 1
  inputs = {
    name = "test"
  }
}

terraform plan -destroy -out=plan.out
terraform apply plan.out

more terraform.tfstate

{
  "version": 4,
  "terraform_version": "0.12.19",
  "serial": 22,
  "lineage": "9592d516-e93e-32cb-8d0e-a1844dcc8332",
  "outputs": {},
  "resources": [
    {
      "mode": "data",
      "type": "null_data_source",
      "name": "values",
      "each": "list",
      "provider": "provider.null",
      "instances": []
    }
  ]
}

terraform destroy
more terraform.tfstate

{
  "version": 4,
  "terraform_version": "0.12.19",
  "serial": 23,
  "lineage": "9592d516-e93e-32cb-8d0e-a1844dcc8332",
  "outputs": {},
  "resources": []
}
@ghost
Copy link

ghost commented Mar 28, 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 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.

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

Successfully merging a pull request may close this issue.

2 participants