hashicorp / terraform-exec

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

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

Closed wjf3121 closed 4 months ago

wjf3121 commented 4 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.

Test: all ut and e2e passed, verified the behavior with RWC CLI