---
name: localstack-state
description: Manage LocalStack state and snapshots with lstk. Use when users want to save, load, export, or import LocalStack state, work with Cloud Pods or S3-backed snapshots, or enable persistence across restarts.
title: localstack-state
canonical_url: https://skilld.dev/gh/localstack/skills/state-management
last_updated: 2026-09-25T12:22:41.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install localstack/skills/state-management`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/state-management`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/localstack/skills/state-management) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/state-management`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/state-management --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/state-management --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# State Management

Save, load, and manage LocalStack state for reproducible development environments and state snapshots, using `lstk snapshot` and its `lstk save` / `lstk load` aliases.

## Capabilities

- Save and restore state as local snapshot files
- Save and load state to/from Cloud Pods (LocalStack platform storage)
- Save and load state to/from your own S3 bucket
- Share state across teams via Cloud Pods
- Auto-load a snapshot every time the emulator starts
- Enable persistent state across container restarts

## Prerequisites

- `lstk` installed and authenticated (`lstk login`, or `LOCALSTACK_AUTH_TOKEN` in CI) — see the `localstack` skill
- A running emulator for `save` (`lstk load` will start one for you if needed)

`lstk save` / `lstk load` replace the legacy `localstack state export/import` and `localstack pod save/load` commands with a single snapshot interface. The destination REF decides where the state goes.

## Snapshot References (REF)

| REF form | Destination |
|----------|-------------|
| *(omitted)* | Auto-named local file `./snapshot-<timestamp>-<hex>.snapshot` |
| `./my-snapshot.snapshot` | Explicit local path |
| `pod:my-baseline` | Cloud Pod on the LocalStack platform |
| `pod:my-baseline:3` | Version 3 of that Cloud Pod |
| `my-pod s3://my-bucket/prefix` | Your own S3 bucket |

## Local Snapshots

### Save

```bash
# Save to an auto-named file in the current directory
lstk save

# Save to a specific path (the .snapshot extension is added if omitted)
lstk save ./my-snapshot.snapshot
lstk save /tmp/my-state

# Limit the snapshot to a subset of services
lstk save --services s3,lambda
```

### Load

```bash
# Loads ./my-baseline or ./my-baseline.snapshot
lstk load my-baseline

# Load from an explicit path
lstk load ./checkpoint.snapshot
```

### Use Cases for Local Snapshots

- **Backup/restore**: Save state before destructive operations
- **CI/CD pipelines**: Commit snapshot files to version control for reproducible tests
- **Offline workflows**: Work with snapshot files without cloud connectivity
- **Quick snapshots**: Fast local save/restore during development

## Cloud Pods

Cloud Pods store state on the LocalStack platform, enabling team collaboration and remote state management. They require authentication (`lstk login` or `LOCALSTACK_AUTH_TOKEN`).

### Save to a Cloud Pod

```bash
lstk save pod:my-baseline

# Only part of the state
lstk save pod:my-baseline --services s3,lambda
```

Every save to an existing pod name creates a new version.

### Load from a Cloud Pod

```bash
lstk load pod:my-baseline

# A specific version
lstk load pod:my-baseline:3

# Preview the changes without applying them (Cloud Pod refs only)
lstk load pod:my-baseline --dry-run
```

### List, Inspect, and Remove

```bash
# Your Cloud Pods
lstk snapshot list

# Everything in your organisation
lstk snapshot list --all

# Metadata: created date, size, LocalStack version, per-service resource counts
lstk snapshot show pod:my-baseline
lstk snapshot show pod:my-baseline:3

# Version history
lstk snapshot versions pod:my-baseline

# Delete (cloud snapshots only, cannot be undone)
lstk snapshot remove pod:my-baseline
lstk snapshot remove pod:my-baseline --force
```

### Use Cases for Cloud Pods

- **Team collaboration**: Share consistent development environments across team members
- **Demo environments**: Prepare and share demo-ready states
- **Cross-machine development**: Access the same state from different machines

## S3-Backed Snapshots

Store snapshots in a bucket you own. Credentials are read from `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`, from `--profile`, or from the profile named by `AWS_PROFILE` — never put credentials in the URL.

```bash
lstk save my-pod s3://my-bucket/prefix
lstk save my-pod s3://my-bucket/prefix --profile my-aws-profile

lstk load my-pod s3://my-bucket/prefix

lstk snapshot list s3://my-bucket/prefix
```

## Merge Strategies

`lstk load` controls how snapshot state combines with state already in the emulator:

| Strategy | Behavior |
|----------|----------|
| `account-region-merge` *(default)* | Snapshot wins on overlapping (service, account, region) |
| `overwrite` | Wipe running state, then load |
| `service-merge` | Snapshot wins per resource; non-overlapping resources are combined |

```bash
lstk load pod:my-baseline --merge=overwrite
```

You can also set `LSTK_MERGE_STRATEGY` instead of passing the flag.

## Auto-Loading a Snapshot on Start

For the AWS emulator, set the `snapshot` field on the container block so a snapshot loads on every start:

```toml
[[containers]]
type     = "aws"
snapshot = "pod:my-baseline"
```

Override or skip it for a single run:

```bash
lstk start --snapshot pod:other-baseline
lstk start --no-snapshot
```

## Local Persistence

For automatic persistence across restarts without explicit save/load:

```bash
lstk start --persist
lstk restart --persist
```

`--persist` injects `LOCALSTACK_PERSISTENCE=1` and writes state to the mounted volume, which is reloaded on the next start. Find that directory with `lstk volume path`; wipe it with `lstk volume clear`.

You can also set `PERSISTENCE = "1"` in an `[env.*]` profile in `config.toml` to make it the default for every run.

## Clearing State

```bash
# Discard in-memory resources, keep the emulator running
lstk reset

# Wipe the on-disk volume (stop the emulator first)
lstk volume clear
```

## Comparison

| Feature | Local snapshot files | Cloud Pods (`pod:`) | Your S3 bucket (`s3://`) |
|---------|----------------------|---------------------|--------------------------|
| Storage | Local files | LocalStack platform | Your AWS account |
| Extra auth | None beyond `lstk` | LocalStack auth token | AWS credentials |
| Team sharing | Manual file sharing | Built-in | Via bucket permissions |
| Versioning | Manual | Built-in (`snapshot versions`) | Manual |
| Offline use | Yes | No | No |

Note that `lstk` itself always requires a LocalStack account and license, regardless of which snapshot backend you use.

## Best Practices

- Use local snapshot files for development checkpoints and CI/CD pipelines
- Use Cloud Pods for team collaboration and shared environments
- Use descriptive names that indicate the state contents
- Use `--services` to keep snapshots small when you only care about part of the stack
- Use `--dry-run` before loading an unfamiliar Cloud Pod into a populated emulator
- Use `lstk start --persist` for simple state retention across restarts
