resource "null_resource" "sql_commands" {
triggers = {
...
}
provisioner "local-exec" {
command = "./sql.sh"
environment = {
ACTION = "create"
...
}
}
provisioner "local-exec" {
when = destroy
command = "./sql.sh"
environment = {
...
}
}
}
In my use case, the destroy
provisioner is intended to run only when I am removing the resource entirely (for good). However, the destroy
script will actually run any time the resource is updated, because an update is fulfilled by a replace
(for this resource type), which is actually a destroy
followed by a create
. The workaround here is to do the apply in multiple steps - first removing the destroy
provisioner, then adding it back. But this seems cumbersome and error prone.