-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
terraform_data ignoring local-exec destroy provisioner #34711
Comments
Current workaround is to use count with terraform_data like it's documented in https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax#destroy-time-provisioners, but that isn't my understanding of a destroy trigger. |
Hi @leuthelt, In your reproduction steps you mentioned commenting out the entire resource block. That means that you removed the provisioner from the configuration, and so Terraform didn't execute it. Therefore Terraform seems to have worked as designed here. If you want the provisioner to run then you must keep it in the configuration. I think therefore that this issue is a feature request for a way to keep the destroy provisioner in the configuration even though the containing resource block has been removed, so that the instructions about what to do when destroying the object can outlive the declaration of the object. Would you agree? |
Hi @apparentlymart, I would agree to your comment. |
Thank you for confirming. This situation is one of the future improvements we considered when recently introducing the If we did that then instead of removing the block entirely you would replace it with a # NOTE: not a working example yet;
# hypothetical future language feature
removed {
from = terraform_data.destroy_action
provisioner "local-exec" {
when = destroy
command = "echo 'Destroy-time provisioner'"
}
} The idea here then is that We have also considered a helper command like |
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. |
Terraform Version
Terraform Configuration Files
resource "terraform_data" "destroy_action" {
provisioner "local-exec" {
when = destroy
command = "echo 'Destroy-time provisioner'"
}
}
Debug Output
https://gist.github.com/leuthelt/aa9760f8ec5d4279261aa0e9857be418
Expected Behavior
Terraform should run the defined local-exec command during destroy.
Actual Behavior
Terraform is removing terraform_data resource from state without executing local-exec command.
Steps to Reproduce
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered: