-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Triggering local-exec Provisioners During terragrunt destroy #3764
Comments
Hey @Saibhargav2118 , Nothing Terragrunt does interacts with how OpenTofu/Terraform run their providers. If you configure OpenTofu/Terraform to use any of those features, they should do the same thing when being called by Terragrunt. That being said, if you're encountering a bug, I would need logs and a fixture (some code that I can run) to reproduce your issue. In general, if Terragrunt maintainers can't reproduce an issue you're facing our odds of resolving them are much lower. As a matter of general practice, most Terragrunt users don't have to rely on If you haven't had a chance, I recommend reading through the Getting Started guide. |
@yhakbar Here is the code that I want to execute ECS command during terragrunt destroy. resource "null_resource" "ontap_unpeer" { lifecycle { triggers = { depends_on = [module.ontap-cluster-peering] |
@Saibhargav2118 did you get a chance to read these docs? |
Hello Terragrunt team,
I'm currently using Terragrunt to manage my infrastructure with Terraform, and I have encountered a challenge that I hope to get some clarity on. I am trying to trigger a local-exec provisioner (or any cleanup process) during the terragrunt destroy phase, similar to how provisioners work during terraform apply.
However, based on my testing and documentation review, it seems that provisioners, particularly local-exec, are not triggered during the destroy phase with Terragrunt. This limitation makes it difficult for me to run cleanup tasks, such as logging or removing certain temporary files, when the resources are being destroyed.
Here are a few things I’ve tried:
Using the when = destroy option within a local-exec provisioner.
Utilizing null_resource with lifecycle and triggers to force execution during destroy.
Running terraform destroy manually with an external script to handle post-destroy actions.
While some of these methods have worked in isolated Terraform configurations, they don't seem to trigger properly with Terragrunt, or they don’t address my full use case.
My question is:
Is there a recommended way to trigger a local-exec or any cleanup provisioner during the terragrunt destroy operation? Or, alternatively, is there a way to reliably trigger post-destroy actions in a Terragrunt-managed environment?
Any insights or workarounds would be greatly appreciated!
Thank you!
The text was updated successfully, but these errors were encountered: