# How to trigger after destroy confirmation?

**URL:** <https://discuss.hashicorp.com/t/how-to-trigger-after-destroy-confirmation/34997>\
**Category:** Vagrant\
**Created:** [January 31, 2022, 12:10pm UTC](https://discuss.hashicorp.com/t/how-to-trigger-after-destroy-confirmation/34997 "2022-01-31T12:10:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Perza](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/perza/32/17994_2.png) [@Perza](https://discuss.hashicorp.com/u/Perza)\
**Post date:** [January 31, 2022, 12:10pm UTC](https://discuss.hashicorp.com/t/how-to-trigger-after-destroy-confirmation/34997/1 "2022-01-31T12:10:15Z")

</div>

I have a use case where I’d need to run few tasks on a VM while it’s running and before it’s getting destroyed. To achieve this, I added a trigger  
MyVM.trigger.before :destroy do |trigger|.

It works, but runs before the destroy confirmation which is a bit bad. Then I started running vagrant destroy --debug to find out what classes it runs so that I could run the trigger after the destroy confirmation.

I added the following

- to start of the script  
VAGRANT\_EXPERIMENTAL=“typed\_triggers”

- under my VM (I would change “before” to “after” when it triggers correctly):  
MyVM.trigger.before :“Vagrant::Action::Builtin::DestroyConfirm”, type: :action do |trigger|  
trigger.info = “Running post tasks INFO”  
trigger.warn = “Running post tasks WARNING”

However, it never triggers

DEBUG config: Trigger defined for: Vagrant::Action::Builtin::DestroyConfirm  
…  
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000  
DEBUG subprocess: Exit status: 0  
INFO warden: Calling OUT action: #VagrantPlugins::ProviderVirtualBox::Action::Created:0x000001538179e728  
INFO runner: Running action: machine\_action\_destroy #Vagrant::Action::Warden:0x00000153823647d8  
INFO warden: Calling IN action: #\<Proc:0x0000015382222258 C:/HashiCorp/Vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/warden.rb:126 (lambda)\>  
INFO warden: Calling IN action: #Vagrant::Action::Builtin::Call:0x00000153823646c0  
INFO runner: Running action: machine\_action\_destroy #Vagrant::Action::Builder:0x0000015382142a90  
INFO warden: Calling IN action: #Vagrant::Action::Builtin::DestroyConfirm:0x00000153820660b8  
INFO interface: ask: Are you sure you want to destroy the ‘MyVM’ VM? [y/N]  
INFO interface: ask: MyVM: Are you sure you want to destroy the ‘MyVM’ VM? [y/N]  
MyVM: Are you sure you want to destroy the ‘MyVM’ VM? [y/N]

what could be the issue here?
