diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d59416..ea288f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Terraform deploy now sends sigint to terraform on ctrl+C, giving it a chance + to shut down a little more gracefully. + ## [4.1.0] - 2024-02-16 ### Added diff --git a/terraform/deployment/terraform.py b/terraform/deployment/terraform.py index bf3a5cd..89236f2 100644 --- a/terraform/deployment/terraform.py +++ b/terraform/deployment/terraform.py @@ -6,6 +6,7 @@ import os import pathlib import shutil +import signal import subprocess import sys import typing @@ -20,9 +21,11 @@ def _setup_sources(source: pathlib.Path) -> None: def _run_terraform(command: str, args: typing.List[str] = None) -> None: - subprocess.check_call( - ["terraform", command, "-lock-timeout=300s", "-input=false"] + (args or []), - ) + try: + subprocess.Popen(["terraform", command, "-lock-timeout=300s", "-input=false"] + (args or [])) as process: + process.wait() + except KeyboardInterrupt: + process.send_signal(signal.SIGINT) def apply(args: argparse.Namespace) -> None: