Schedule automatic destruction of Terraform/OpenTofu infrastructure. Run killalltofu 1h from a project directory, and after that duration, the infrastructure gets torn down automatically via cron.
brew tap killallgit/killallgit
brew install killalltofuOr install directly:
brew install killallgit/killallgit/killalltofucargo install --git https://github.com/killallgit/killalltofuDownload pre-built binaries from GitHub Releases.
cd my-infra-project
killalltofu 1h # destroy in 1 hour
killalltofu 30m # destroy in 30 minutes
killalltofu 2d # destroy in 2 daysThis registers the current directory for scheduled destruction and installs a cron job that checks every minute.
A .killalltofu marker file is written to the project directory with the scheduled destruction time.
killalltofu listNAME DESTROY AT ENGINE ATTEMPTS
users-ryan-code-my-infra 2026-03-02T17:00:00Z tofu 0/3
users-ryan-code-staging 2026-03-03T00:00:00Z terragrunt 1/3
cd my-infra-project
killalltofu cancelcd my-infra-project
killalltofu kill # destroy current directory
killalltofu kill --name some-key # destroy by registry keyRuns the destroy command inline, blocking, and streams output to the terminal.
killalltofu <duration>writes an entry to~/.killalltofu/registry.jsonand installs a cron entry (* * * * * killalltofu check) if not already present- Every minute, cron runs
killalltofu check, which processes any entries past their destroy time - On success: removes the
.killalltofumarker and unregisters the project - On failure: retries up to 3 times with backoff, then writes a
.killallerrorfile
Concurrent access to the registry is protected by file locks (~/.killalltofu/registry.lock) — shared locks for reads, exclusive locks for writes. The registry is written atomically (write to temp file, then rename).
- If
terragrunt.hclis present in the project directory:terragrunt destroy -auto-approve - Otherwise: tries
tofufirst, falls back toterraform->destroy -auto-approve
The absolute binary path is resolved at registration time and stored in the registry, so cron doesn't depend on PATH.
| Attempt | Timing |
|---|---|
| 1 | At scheduled time |
| 2 | 5 minutes after attempt 1 |
| 3 | 15 minutes after attempt 2 |
| After 3 | Writes .killallerror, stops retrying |
Attempt logs are saved to ~/.killalltofu/logs/.
~/.killalltofu/
registry.json # registered projects
registry.lock # file lock for concurrent access
logs/
<key>-attempt-<n>.log
<project-dir>/
.killalltofu # marker file with destroy_at timestamp
.killallerror # written on max retry failure
Add .killalltofu and .killallerror to your project's .gitignore.
A test fixture is included that uses the Docker provider — no cloud account needed. Requires Docker running locally and OpenTofu installed.
cd tests/fixtures/docker-nginx
tofu init
tofu apply -auto-approve # spins up nginx on localhost:8088
curl localhost:8088 # verify it's runningThen test killalltofu against it:
# schedule destruction in 2 minutes
killalltofu 2m
# or destroy immediately
killalltofu kill
# verify container is gone
docker ps | grep killalltofu-testMIT