Skip to main content

keepstack

Your local AWS survives restarts.

Persistent state for AWS Emulator. Reboot, come back days later, and terraform plan still says No changes.

CI License: Apache-2.0 Python 3.10+ Zero dependencies

Quick start · How it works · Compatibility · Contributing
English · Español · 简体中文


The problem

AWS Emulator is AWS's official local emulator: fast and faithful, but everything lives in memory.

😩 Without keepstack 😌 With keepstack
$ terraform apply      # 30 resources
$ # ...reboot...
$ terraform plan
Plan: 30 to add, 0 to change, 0 to destroy.

Everything is gone. Terraform wants to rebuild the whole stack, and you can't see the one change you made.

$ terraform apply      # 30 resources
$ # ...reboot...
$ terraform plan
No changes. Your infrastructure matches
the configuration.

Same VPCs, same IDs, same data. Add a subnet and plan shows exactly 1 to add.

Quick start

Requirements: Docker and Python 3.10+.

1. Install

pipx install keepstack         # or: uv tool install keepstack

2. Start it: the emulator image is built on first run, then your saved state is restored

keepstack up -d                # in the background; or `keepstack up` to keep it in this terminal

3. Point your tools at it

eval "$(keepstack env)"        # PowerShell: keepstack env --shell powershell | iex
aws sts get-caller-identity    # "Account": "000000000000" → you're on the emulator

That's it. Use Terraform, the AWS CLI or any SDK as usual, and keepstack down whenever you like. Try the full loop with examples/quickstart.

Everyday commands

Command What it does
keepstack check Before applying: lists which resources in your Terraform project will work on the emulator, which are known to break (with workarounds) and the emulator's known gaps for each service you use. Exits 1 if something will fail, so it fits in CI.
keepstack up -d / down Run in the background / stop it. The state is kept either way.
keepstack status Is it running? How many calls are saved, per service, and how did the last restore go.
keepstack ui Open the web dashboard: resources, recent calls, ID translations and snapshots.
keepstack logs -f Follow the background log.
keepstack doctor Checks Docker, the port, your AWS CLI version and warns if real AWS credentials could leak into your session.
keepstack snapshot save <name> Save the current state (add --include terraform.tfstate to save your Terraform state with it). snapshot list, restore, delete.
keepstack export / import Share a whole environment as a single file.
keepstack compact Shrink the journal by dropping resources that were created and later deleted. Verified in a throwaway emulator before it is applied.
keepstack env Print the variables that point your tools at keepstack.
$ keepstack check examples/quickstart
keepstack check: examples/quickstart (scanned .tf files), emulator 1.0.322

⚠ works with a caveat
    aws_dynamodb_table          x1  PAY_PER_REQUEST shows a perpetual diff (OnDemandThroughput returns -1)
                                workaround: keepstack up --shims, or lifecycle { ignore_changes = [on_demand_throughput] }

✓ ok
    aws_kms_key                 x1  key UUID translated by keepstack
    aws_route53_zone            x1  zone ID translated by keepstack
    aws_subnet                  x2
    aws_vpc                     x1
    ...

14 resources: 13 ok, 1 with caveats, 0 broken, 0 untested.

Snapshots make risky changes cheap to try:

keepstack snapshot save before-upgrade --include terraform.tfstate
terraform apply                                     # ...didn't go well?
keepstack down && keepstack snapshot restore before-upgrade && keepstack up -d

Dashboard

keepstack ui opens a read-only dashboard served by keepstack itself, on the same port. It shows what exists in your local AWS according to the journal, the latest calls (click one to see the request and response), the ID translations and your snapshots. It only answers on 127.0.0.1.

keepstack dashboard

In GitHub Actions

Give any workflow a local AWS with one step. Your AWS CLI, SDKs and Terraform are pointed at it automatically.

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: sanlega/keepstack@v0.2.0
        with:
          shims: true          # optional: work around known emulator bugs
          cache: true          # optional: keep the state between runs
      - run: terraform init && terraform apply -auto-approve
Input Default Description
shims false Same as keepstack up --shims
cache false Restore the state from the previous run and save it at the end of the job
cache-key keepstack Cache key prefix, for independent environments
port 9297 Port keepstack listens on
data-dir .keepstack State directory
python-version 3.12 Python used to run keepstack

The action needs a Linux runner (Docker with Linux containers). Output: endpoint-url.

Features

🔁 Survives everything Ctrl+C, docker kill, Docker restarts, reboots. If the container dies, keepstack restores it on its own.
🪪 Stable IDs vpc-…, KMS UUIDs, Secrets Manager ARNs, Route 53 zone IDs… keep their original values across restarts.
🔍 Know before you apply keepstack check tells you what will break on the emulator before you run Terraform.
📸 Snapshots Save, restore and share whole environments, Terraform state included.
🩹 Compatibility shims --shims works around known emulator bugs (e.g. aws_security_group), off by default.
⚡ Zero setup One command, no config. The emulator image builds itself (x86_64 and Apple silicon).
🛡️ Safe by design Write-ahead journal, one instance per port: a stray --reset can't wipe a running state.
📦 Zero dependencies Pure Python standard library. macOS, Linux and Windows.
✅ Tested for real 40+ Terraform resource types, end-to-end against a real emulator. See the matrix →

How it works

flowchart LR
    T["Terraform<br/>AWS CLI · SDKs"] -- "http :9297" --> K["keepstack"]
    K -- "https :9298" --> E["AWS Emulator<br/>(Docker)"]
    K <--> J[("journal.db<br/>SQLite")]
  1. Record: every write is saved to the journal before it reaches the emulator. Reads pass straight through.
  2. Replay: on start, a clean emulator receives the journal in order (with retries for resources still settling).
  3. Translate: new random IDs are mapped back to the originals, so your tools never notice the restart.

State lives in .keepstack/ next to where you run it, one state per project, like .terraform/. The full design is in docs/how-it-works.md.

Reference

Commands and options
keepstack up        [-d] [--port 9297] [--emulator-port 9298] [--data-dir .keepstack]
                    [--image keepstack-emulator] [--reset] [--shims] [--verbose]
keepstack down      [--data-dir]
keepstack status    [--data-dir] [--json]
keepstack logs      [--data-dir] [-f]
keepstack env       [--port 9297] [--shell sh|powershell|dotenv]
keepstack ui        [--port 9297] [--no-browser]
keepstack check     [PATH] [--plan plan.json] [--offline] [--json]
keepstack doctor    [--port] [--data-dir]
keepstack snapshot  save NAME [--include FILE ...] [--force] | list | restore NAME | delete NAME
keepstack export    FILE
keepstack import    FILE
keepstack compact   [--dry-run]
keepstack --version

Every command that works on a state accepts --data-dir (default .keepstack). restore, import and compact need keepstack to be stopped and save the previous state as the pre-restore / pre-compact snapshot first, so they can always be undone.

Option Default Description
--port 9297 Port your tools connect to (plain HTTP on 127.0.0.1)
--emulator-port 9298 Internal port of the emulator container
--data-dir .keepstack Where the journal is stored
--image keepstack-emulator Emulator image; built automatically if it's the default and missing
--reset Clear the saved state and start from scratch
-d, --detach Run in the background; logs go to .keepstack/keepstack.log
--shims Work around known emulator bugs (see how it works); remembered for that state
--verbose Log every request

Run several isolated environments side by side with different --port, --emulator-port and --data-dir.

Limitations
  • Local development only: no credential checks, emulator runs with --auth off, bound to 127.0.0.1. See SECURITY.md.
  • It is not AWS: the emulator doesn't evaluate IAM and its fidelity varies by service. Known gaps are in the compatibility matrix.
  • Heuristic ID translation: only values that look generated are learned. Details in how it works.
  • The journal only grows: compact it with keepstack up --reset and a fresh terraform apply.

Contributing

Issues and PRs are welcome, especially new entries for the compatibility matrix. Start with CONTRIBUTING.md.

License

Apache-2.0

keepstack is an independent project, not affiliated with, endorsed by or sponsored by Amazon Web Services. AWS and AWS Emulator are trademarks of Amazon.com, Inc. or its affiliates.

Metadata

Release files for keepstack 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keepstack 0.2.0
File Size Uploaded Provenance Actions
keepstack-0.2.0.tar.gz 78.8 kB With provenance Details for keepstack-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for keepstack 0.2.0
File Interpreter ABI Platform Actions
keepstack-0.2.0-py3-none-any.whl Python 3 none any Details for keepstack-0.2.0-py3-none-any.whl

Total release size: 140.0 kB

Release files / keepstack-0.2.0.tar.gz

Download URL keepstack-0.2.0.tar.gz
Size 78.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0e058a56c61a6bd78e243e75ff88c3a57e87438784daaa751f5a86de9411c3f6
BLAKE2b-256 checksum
How to use checksums
9e9a94195b93881ffa094d9999e5097e8abefb70ec0975cb69e6eb8abfde2641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / keepstack-0.2.0-py3-none-any.whl

Download URL keepstack-0.2.0-py3-none-any.whl
Size 61.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3bcc2544b7ee2eec3fa7d22a2a065710dde52469be1cfe5bb0466fc01e9a3bb
BLAKE2b-256 checksum
How to use checksums
14c772041c9d587cd57a2b72dd516129e3c20a1735fde8f093b12a5846db87e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for keepstack 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for keepstack-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page