Skip to content

Commit fd84986

Browse files
gtsiolisclaude
andcommitted
docs(lstk): update CLI reference to v0.22.2
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9891919 commit fd84986

6 files changed

Lines changed: 81 additions & 13 deletions

File tree

src/content/docs/aws/developer-tools/running-localstack/lstk/authentication.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ tags: ['Hobby']
77

88
`lstk` resolves your auth token in the following order:
99

10-
1. **System keyring**: a token stored by a previous `lstk login`.
11-
2. **`LOCALSTACK_AUTH_TOKEN` environment variable**: used only when the keyring has no token.
10+
1. **`LOCALSTACK_AUTH_TOKEN` environment variable**: takes precedence over a stored token.
11+
2. **System keyring**: a token stored by a previous `lstk login`, used when the environment variable is not set.
1212
3. **Browser login**: triggered automatically in interactive mode when neither of the above provides a token.
1313

14-
:::caution
15-
The keyring token takes precedence over `LOCALSTACK_AUTH_TOKEN`.
16-
If you set or change the environment variable but a keyring token already exists, the environment variable is ignored.
17-
Run `lstk logout` to clear the stored keyring token first.
14+
:::note
15+
`LOCALSTACK_AUTH_TOKEN` takes precedence over a token in the keyring.
16+
A per-invocation token (a CI secret, or `LOCALSTACK_AUTH_TOKEN=... lstk start` for a second account) therefore overrides a previous `lstk login` without needing `lstk logout` first.
17+
To go back to the stored token, unset the environment variable.
1818
:::
1919

2020
## Logging in

src/content/docs/aws/developer-tools/running-localstack/lstk/automation.mdx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ These options are available for all commands:
1212
| Option | Description |
1313
|:--------------------|:------------------------------------------------------------------------------|
1414
| `--config <path>` | Path to a specific TOML config file |
15+
| `--endpoint-url <url>` | Target an existing, externally-managed emulator at this URL instead of discovering one via local Docker. See [Targeting an external emulator](#targeting-an-external-emulator). |
1516
| `--non-interactive` | Disable the interactive TUI, use plain output |
1617
| `--json` | Emit a single machine-readable JSON envelope on stdout instead of human-oriented output. Supported by `stop`, `reset`, and `update`; any other command rejects it. See [Structured output](#structured-output). |
1718
| `--persist` | Persist emulator state across restarts (on `start`/bare `lstk` and `restart`) |
@@ -42,6 +43,28 @@ Commands that mutate state without prompting in CI (`reset`, `volume clear`) req
4243
`lstk setup aws` works non-interactively — it writes the profile with defaults and needs `--force` only to overwrite a conflicting `localstack` profile.
4344
:::
4445

46+
## Targeting an external emulator
47+
48+
By default `lstk` discovers the emulator it manages through local Docker.
49+
The `--endpoint-url <url>` global flag (or the `LSTK_ENDPOINT_URL` environment variable) instead points a command at an emulator `lstk` did not start — a Docker Compose or host-network deployment, one running in CI or on another machine, or a LocalStack cloud-hosted ephemeral instance.
50+
51+
```bash
52+
# Run against an emulator reachable at a custom URL
53+
lstk aws --endpoint-url http://localhost:4566 s3 ls
54+
55+
# Equivalent via the environment
56+
LSTK_ENDPOINT_URL=https://my-ephemeral-instance.localstack.cloud lstk status
57+
```
58+
59+
The endpoint is resolved from, in order of precedence: the `--endpoint-url` flag, `LSTK_ENDPOINT_URL`, then `AWS_ENDPOINT_URL` (a full synonym for `LSTK_ENDPOINT_URL`, one tier lower).
60+
Both `http://` and `https://` URLs are accepted (any other scheme is rejected), and the scheme is preserved end-to-end, so `https://` ephemeral instances work.
61+
62+
The commands that accept an external endpoint are the ones that only *talk to* an already-running emulator: [`aws`](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/#aws), [`az`](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/#az), [`terraform`](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/#terraform)/`tf`, [`cdk`](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/#cdk), [`sam`](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/#sam), [`status`](/aws/developer-tools/running-localstack/lstk/lifecycle-commands/#status), [`reset`](/aws/developer-tools/running-localstack/lstk/lifecycle-commands/#reset), and the [`snapshot`](/aws/developer-tools/running-localstack/lstk/snapshots/) `save`/`load`/`remove` subcommands (including the `lstk save`/`lstk load` aliases) and `list s3://…`.
63+
64+
Commands that manage the emulator's lifecycle or on-disk state have no remote equivalent and **reject** any endpoint source: `start`, the bare `lstk`, `stop`, `restart`, `logs`, and `volume`.
65+
66+
The emulator's type (AWS, Azure, or Snowflake) is auto-detected by probing the endpoint's health API — there is no override flag or config setting, and an inconclusive probe is a hard failure. The AWS-only tools (`terraform`, `cdk`, `sam`) reject an endpoint whose detected type is not AWS.
67+
4568
## Structured output
4669

4770
The global `--json` flag makes a command emit a single, machine-readable JSON object on stdout instead of human-oriented text, for scripting and CI.
@@ -115,7 +138,8 @@ The following environment variables configure `lstk` itself (not the LocalStack
115138

116139
| Variable | Description |
117140
|:-------------------------------|:---------------------------------------------------------------------------------------------------------------------|
118-
| `LOCALSTACK_AUTH_TOKEN` | Auth token for non-interactive runs or to skip browser login. Used when no keyring token is stored. |
141+
| `LOCALSTACK_AUTH_TOKEN` | Auth token for non-interactive runs or to skip browser login. Takes precedence over a token stored in the keyring. |
142+
| `LSTK_ENDPOINT_URL` | Target an existing, externally-managed emulator at this URL (equivalent to `--endpoint-url`). `AWS_ENDPOINT_URL` is a lower-precedence synonym. See [Targeting an external emulator](#targeting-an-external-emulator). |
119143
| `LOCALSTACK_HOST` | Override the host (and optional port) used when resolving and printing the emulator endpoint, and when writing the AWS CLI profile. Bypasses the `localhost.localstack.cloud` DNS probe. |
120144
| `LOCALSTACK_DISABLE_EVENTS` | Set to `1` to disable anonymous telemetry event reporting. |
121145
| `DOCKER_HOST` | Override the Docker daemon socket (e.g. `unix:///home/user/.colima/default/docker.sock`). |

src/content/docs/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tags: ['Hobby']
1010
:::note
1111
Like `lstk aws`, the `az`, `terraform`, `cdk`, and `sam` proxies do not start the emulator — start it first with [`lstk start`](/aws/developer-tools/running-localstack/lstk/lifecycle-commands/#start).
1212
Each requires the corresponding third-party CLI to be installed and on your `PATH`.
13+
To run any of them against an emulator `lstk` did not start, pass [`--endpoint-url`](/aws/developer-tools/running-localstack/lstk/automation/#targeting-an-external-emulator) (or set `LSTK_ENDPOINT_URL`).
1314
:::
1415

1516
:::note
@@ -40,6 +41,7 @@ The exit code and `stdout`/`stderr` of the underlying `aws` process are passed t
4041

4142
| Option | Description |
4243
|:--------------------|:--------------------------------------------------------------------------------------------------|
44+
| `--account <id>` | Target a specific 12-digit LocalStack account (default `000000000000`). Must appear **before** the `aws` subcommand. Falls back to a 12-digit `AWS_ACCESS_KEY_ID`. See [Selecting the account](#selecting-the-account). |
4345
| `--non-interactive` | Suppress the loading spinner. Unlike other commands, this flag is stripped before invoking `aws` (not forwarded). |
4446

4547
:::note
@@ -62,6 +64,20 @@ By default, `lstk` probes whether `localhost.localstack.cloud` resolves to `127.
6264
Set [`LOCALSTACK_HOST`](/aws/developer-tools/running-localstack/lstk/automation/#environment-variables) to override the host:port used to reach LocalStack and skip the DNS probe.
6365
The port comes from the AWS container's `port` in `config.toml` (default `4566`).
6466

67+
### Selecting the account
68+
69+
LocalStack derives the AWS account from the access key id it receives, so `lstk aws --account <id>` targets a specific 12-digit LocalStack account by controlling the credentials `aws` runs with (a neutral, real-looking `AKIA…`/`ASIA…` key never reaches the emulator):
70+
71+
```bash
72+
lstk aws --account 111111111111 s3 mb s3://my-bucket
73+
```
74+
75+
The flag must appear **before** the `aws` subcommand (placing it after is a placement error, not silently forwarded). When it is omitted, `lstk` falls back to a 12-digit `AWS_ACCESS_KEY_ID` if one is set, then to the default account `000000000000`. The same leading-flag account selection is available on [`lstk terraform`](#terraform) and [`lstk sam`](#sam); `lstk cdk` does not support it.
76+
77+
### Tab completion
78+
79+
`lstk aws <TAB>` completes AWS services, operations, and parameters using the AWS CLI's own completer. It is enabled together with the rest of `lstk`'s completion — see [Shell completions](/aws/developer-tools/running-localstack/lstk/#shell-completions).
80+
6581
## `az`
6682

6783
Run Azure CLI commands against the running LocalStack Azure emulator.

src/content/docs/aws/developer-tools/running-localstack/lstk/configuration.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ The default `config.toml` created on first run. The `type` field reflects whiche
4141
type = "aws" # Emulator type. Supported: "aws", "snowflake", "azure"
4242
tag = "latest" # Docker image tag, e.g. "latest", "2026.4"
4343
port = "4566" # Host port the emulator will be accessible on
44+
# container_name = "" # Override the derived container name (also MAIN_CONTAINER_NAME)
4445
# image = "" # Full image override (e.g. an internal mirror or offline image)
46+
# expose_ports = [] # Extra container ports to publish, e.g. [53] for the DNS server
4547
# volume = "" # Host directory for persistent state (default: OS cache dir)
4648
# volumes = [] # Docker-style "host:container[:ro]" bind mounts (see Volumes)
4749
# env = [] # Named environment profiles to apply (see [env.*] sections below)
@@ -55,7 +57,9 @@ port = "4566" # Host port the emulator will be accessible on
5557
| `type` | string | `"aws"` | Emulator type. One of `"aws"`, `"snowflake"`, `"azure"`. Run a single `[[containers]]` block at a time. See [Emulator types](#emulator-types). |
5658
| `tag` | string | `"latest"` | Docker image tag (`"latest"`, `"2026.4"`, etc.). Useful for pinning a specific version. Zero-padded months (`"2026.04"`) are normalized to `"2026.4"`. |
5759
| `port` | string | `"4566"` | Host port the emulator listens on (1–65535). The in-container port is always `4566`. |
60+
| `container_name` | string | (derived) | Override the derived container name (`localstack-<type>`, plus `-<tag>` when `tag` is not `"latest"`). This is also what the emulator reports as `MAIN_CONTAINER_NAME`. Set it when something outside `lstk` addresses the emulator by a fixed name, e.g. a sidecar proxy on a CI agent. |
5861
| `image` | string | (default) | Full image reference that overrides the default Docker Hub image, e.g. an internal-registry mirror or a locally loaded offline image. If it already carries a tag, `tag` is ignored; otherwise `tag` (or `latest`) is appended. |
62+
| `expose_ports` | (int \| string)[] | `[]` | Publish additional container ports on the host, beyond the gateway and service ports `lstk` publishes by default. Each entry is a bare port number (published on the same host port) or a Docker-style `"[host:]container[/proto]"` string — e.g. `expose_ports = [53]` to use the emulator's DNS server as the host's resolver, or `expose_ports = ["5354:5353/udp"]`. |
5963
| `volume` | string | (OS cache) | Host directory for persistent emulator state. Defaults to `<os-cache>/lstk/volume/<container-name>`. See also `volumes`. |
6064
| `volumes` | string[] | `[]` | Docker-style `"host:container[:ro]"` bind mounts (e.g. init hooks). May also carry the persistence mount (target `/var/lib/localstack`). See [Volume mounts](#volume-mounts). |
6165
| `env` | string[] | `[]` | List of named environment profiles to inject into the container (see below). |

src/content/docs/aws/developer-tools/running-localstack/lstk/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ This section is split into focused pages:
2929
- [Configuration](/aws/developer-tools/running-localstack/lstk/configuration/): the `config.toml` file, emulator types, environment variables, and volumes.
3030
- [Lifecycle commands](/aws/developer-tools/running-localstack/lstk/lifecycle-commands/): `start`, `stop`, `restart`, `status`, `logs`, `reset`, `volume`.
3131
- [Cloud & IaC commands](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/): `aws`, `az`, `terraform`, `cdk`, `sam`.
32-
- [Snapshots](/aws/developer-tools/running-localstack/lstk/snapshots/): save and load emulator state with `snapshot save`/`load`/`list`/`remove`/`show`.
33-
- [Automation & CI](/aws/developer-tools/running-localstack/lstk/automation/): global options, non-interactive mode, structured output, and environment variables.
32+
- [Snapshots](/aws/developer-tools/running-localstack/lstk/snapshots/): save and load emulator state with `snapshot save`/`load`/`list`/`remove`/`show`/`versions`.
33+
- [Automation & CI](/aws/developer-tools/running-localstack/lstk/automation/): global options, non-interactive mode, structured output, targeting an external emulator, and environment variables.
3434
- [Setup & maintenance](/aws/developer-tools/running-localstack/lstk/setup-and-maintenance/): `setup`, `config`, `update`, and offline/enterprise environments.
3535
- [FAQ & Troubleshooting](/aws/developer-tools/running-localstack/lstk/faq-and-troubleshooting/).
3636

src/content/docs/aws/developer-tools/running-localstack/lstk/snapshots.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ tags: ['Hobby']
99

1010
Manage emulator snapshots.
1111
A snapshot captures the running emulator's state, either as a local file on disk, as a Cloud Pod on the LocalStack platform, or in your own S3 bucket.
12-
The `snapshot` command groups five subcommands — `save`, `load`, `list`, `remove`, and `show`. The first two are also exposed as the top-level aliases `lstk save` and `lstk load`.
12+
The `snapshot` command groups six subcommands — `save`, `load`, `list`, `remove`, `show`, and `versions`. The first two are also exposed as the top-level aliases `lstk save` and `lstk load`.
1313

1414
:::note
1515
Snapshots are best supported on the **AWS emulator**.
16-
`snapshot save`/`load` (and the `save`/`load` aliases) also work for the Snowflake emulator, but its snapshot support is experimental and not fully tested — `lstk` prints a warning such as `Snapshot support for the snowflake emulator is experimental and not fully tested.`
17-
Azure emulator persistence is still a work in progress and is not yet supported.
16+
`snapshot save`/`load` (and the `save`/`load` aliases) also work for the Snowflake and Azure emulators, but their snapshot support is experimental and not fully tested — for a non-AWS emulator `lstk` prints a warning such as `Snapshot support for the snowflake emulator is experimental and not fully tested.`
1817
:::
1918

2019
## `snapshot save`
@@ -50,6 +49,8 @@ The optional `[destination]` argument takes one of these forms:
5049

5150
Pod operations require an auth token (`LOCALSTACK_AUTH_TOKEN` or a prior `lstk login`); local-file snapshots do not.
5251

52+
Every save to an existing `pod:` snapshot creates a new **version** rather than replacing it; use [`snapshot versions`](#snapshot-versions) to list them and [`snapshot load`](#snapshot-load)/[`snapshot show`](#snapshot-show) with a `pod:<name>:<version>` ref to act on a specific one. `save` itself rejects a version suffix (you cannot save "as version 3").
53+
5354
By default a snapshot captures every service's state. Pass `-s`/`--services` with a comma-separated list to limit it to a subset; this applies uniformly to local files, `pod:` Cloud Pods, and `s3://` remotes.
5455

5556
| Option | Description |
@@ -66,9 +67,12 @@ Load a snapshot into the emulator, **auto-starting it first** if it is not alrea
6667
lstk snapshot load my-baseline
6768
lstk snapshot load ./checkpoint
6869

69-
# Load from a Cloud Pod (requires auth)
70+
# Load from a Cloud Pod (requires auth; latest version)
7071
lstk snapshot load pod:my-baseline
7172

73+
# Load a specific version of a Cloud Pod
74+
lstk snapshot load pod:my-baseline:3
75+
7276
# Load from your own S3 bucket (pod name is required)
7377
lstk snapshot load my-pod s3://my-bucket/prefix
7478

@@ -80,6 +84,7 @@ lstk snapshot load pod:my-baseline --dry-run
8084
```
8185

8286
The `REF` argument is required and identifies a local path/name or a `pod:<name>` Cloud Pod.
87+
For a Cloud Pod you can append a version (`pod:<name>:<version>`) to load an older version; the latest is used when no version is given.
8388
To load from S3, pass the pod name followed by an `s3://bucket/prefix` location (see [S3 remotes](#s3-remotes)).
8489

8590
| Option | Description |
@@ -154,10 +159,29 @@ Show metadata for a single Cloud Pod snapshot on the LocalStack platform: its na
154159
This subcommand is cloud-only and requires authentication.
155160

156161
```bash
162+
# Latest version
157163
lstk snapshot show pod:my-baseline
164+
165+
# A specific version
166+
lstk snapshot show pod:my-baseline:3
167+
```
168+
169+
The required `REF` argument must be a `pod:<name>` Cloud Pod reference.
170+
It defaults to the latest version; append `:<version>` to inspect an older one. Use [`snapshot versions`](#snapshot-versions) to see which versions exist.
171+
172+
## `snapshot versions`
173+
174+
List the version history of a Cloud Pod on the LocalStack platform.
175+
Every save to an existing pod adds a new version; this prints each version's number, created date, LocalStack version, and services.
176+
This subcommand is cloud-only and requires authentication.
177+
178+
```bash
179+
lstk snapshot versions pod:my-baseline
158180
```
159181

160182
The required `REF` argument must be a `pod:<name>` Cloud Pod reference.
183+
Only Cloud Pods have versions — local files and `s3://` remotes do not, and passing a version suffix to `versions` is rejected.
184+
Act on a specific version elsewhere by appending it to the ref, e.g. `lstk snapshot load pod:my-baseline:3` or `lstk snapshot show pod:my-baseline:3`.
161185

162186
## S3 remotes
163187

0 commit comments

Comments
 (0)