-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Destroy provisioners not working if resource is deleted manually #13097
Comments
I am just wondering exactly same thing. I need to detach node from cluster before resource is recreated to prevent trashes left to cluster state. |
Hi @akaspin and @JouniRajalaComiq! Sorry this didn't work out as expected. I totally agree that this is non-ideal and counter-intuitive behavior. Unfortunately this is not a straightforward problem to fix since when the resource is removed from the configuration the configuration for its provisioner is removed too. In order to fix this properly we'd need to retain information in the state file about the set of destroy provisioners as it existed last time the configuration was applied, which we may be able to do in the long run but won't be an easy fix we can attack in the short term. In the mean time I think the best we can do is to mention this explicitly in the documentation and include the following workaround: set Design notes for future reference, for a potential enhancements to support this use-case better: One unintended advantage of splitting out provisioner-like actions into separate top-level resources, as proposed in #6810, is that is then possible for them to "live on" after the resource is removed, thus mitigating this problem. Another way to approach it would be to try to write the provisioner configuration into the state file, but doing that completely generically today is likely to be challenging since Terraform expects configuration to arrive in the shape the HCL decoder presents it, rather than how |
This addresses (via documentation) the issue raised in #13097.
This addresses (via documentation) the issue raised in #13097.
For now I implemented very fast and dirty workaround https://github.com/akaspin/terraform-provider-generic. Just |
Since we have found a few different cases of this similar issue now, I'm going to consolidate this into #13549 as an umbrella, since I expect the fix for all of these will be similar and tackled at the same time. |
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. |
Destroy provisioners only runs on
terraform destroy
or when resource is destroyed by count.But destroy provisioners won't run if resource manually deleted from source file.
Terraform Version
Terraform v0.9.1
Affected Resource(s)
Provisioners
Terraform Configuration Files
Debug Output
Expected Behavior
Destroy provisioner should run.
Actual Behavior
Destroy provisioner doesn't run.
Steps to Reproduce
terraform apply
terraform apply
The text was updated successfully, but these errors were encountered: