Skip to content

Commit

Permalink
⚡ Make terraform deploy forward abort to terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrainerson committed Mar 13, 2024
1 parent dbe1a6f commit bb147cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions terraform/deployment/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import pathlib
import shutil
import signal
import subprocess
import sys
import typing
Expand All @@ -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:
Expand Down

0 comments on commit bb147cd

Please sign in to comment.