Description
While there run_on_start
and run_on_stop
form a nice balance, some run_on_start
scripts are actually meant to be balanced against a run_on_destroy
trigger. As an example, using the run_on_start
scripts to do a git clone
of packages for the workspace, you naturally would not want to delete those when the workspace is stopped, however you might want to delete them when the workspace is destroyed.
A git clone
is of course not a perfect example as we have terraform modules to do that for us already, and furthermore most providers are relying upon the containerization/virtualization provider to do cleanup when workspaces are destroyed, but if there are persistent resources being managed by coder_script
snippets, it would be incredibly handy to have a run_on_destroy
trigger to manage their lifecycles properly.
In my case, this is because I am using Coder to provide access directly to machines that have already been provisioned, and I use remote-exec
to SSH into the devices and install the coder
agent, then coder_script
snippets to set up all kinds of state. I would like to clean that up properly upon workspace destruction.