hashicorp / terraform-exec

Terraform CLI commands via Go.
https://pkg.go.dev/github.com/hashicorp/terraform-exec
Mozilla Public License 2.0
684 stars 114 forks source link

feat: add graceful shutdown option for apply&destroy #454

Open wjf3121 opened 6 months ago

wjf3121 commented 6 months ago

The default behavior of CommandContext is to immediately kill the command process when receiving cancellation signal from the context, which may lead to corrupted terraform state.

This PR adds the option to allow sending interruption signal to the Apply/Destroy command and wait for a graceful period before forcefully killing the process. Note that the option doesn't work on Windows due to the lack of support of sending interrupt signal.