You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/developer-tools/running-localstack/lstk/authentication.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,14 @@ tags: ['Hobby']
7
7
8
8
`lstk` resolves your auth token in the following order:
9
9
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.
12
12
3.**Browser login**: triggered automatically in interactive mode when neither of the above provides a token.
13
13
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.
|`--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). |
15
16
|`--non-interactive`| Disable the interactive TUI, use plain output |
16
17
|`--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). |
17
18
|`--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
42
43
`lstk setup aws` works non-interactively — it writes the profile with defaults and needs `--force` only to overwrite a conflicting `localstack` profile.
43
44
:::
44
45
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
+
45
68
## Structured output
46
69
47
70
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
|`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). |
119
143
|`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. |
120
144
|`LOCALSTACK_DISABLE_EVENTS`| Set to `1` to disable anonymous telemetry event reporting. |
121
145
|`DOCKER_HOST`| Override the Docker daemon socket (e.g. `unix:///home/user/.colima/default/docker.sock`). |
Copy file name to clipboardExpand all lines: src/content/docs/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ tags: ['Hobby']
10
10
:::note
11
11
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).
12
12
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`).
13
14
:::
14
15
15
16
:::note
@@ -40,6 +41,7 @@ The exit code and `stdout`/`stderr` of the underlying `aws` process are passed t
|`--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). |
43
45
|`--non-interactive`| Suppress the loading spinner. Unlike other commands, this flag is stripped before invoking `aws` (not forwarded). |
44
46
45
47
:::note
@@ -62,6 +64,20 @@ By default, `lstk` probes whether `localhost.localstack.cloud` resolves to `127.
62
64
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.
63
65
The port comes from the AWS container's `port` in `config.toml` (default `4566`).
64
66
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):
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
+
65
81
## `az`
66
82
67
83
Run Azure CLI commands against the running LocalStack Azure emulator.
# env = [] # Named environment profiles to apply (see [env.*] sections below)
@@ -55,7 +57,9 @@ port = "4566" # Host port the emulator will be accessible on
55
57
|`type`| string |`"aws"`| Emulator type. One of `"aws"`, `"snowflake"`, `"azure"`. Run a single `[[containers]]` block at a time. See [Emulator types](#emulator-types). |
56
58
|`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"`. |
57
59
|`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. |
58
61
|`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"]`. |
59
63
|`volume`| string | (OS cache) | Host directory for persistent emulator state. Defaults to `<os-cache>/lstk/volume/<container-name>`. See also `volumes`. |
60
64
|`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). |
61
65
|`env`| string[]|`[]`| List of named environment profiles to inject into the container (see below). |
Copy file name to clipboardExpand all lines: src/content/docs/aws/developer-tools/running-localstack/lstk/index.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,8 +29,8 @@ This section is split into focused pages:
29
29
-[Configuration](/aws/developer-tools/running-localstack/lstk/configuration/): the `config.toml` file, emulator types, environment variables, and volumes.
-[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.
34
34
-[Setup & maintenance](/aws/developer-tools/running-localstack/lstk/setup-and-maintenance/): `setup`, `config`, `update`, and offline/enterprise environments.
Copy file name to clipboardExpand all lines: src/content/docs/aws/developer-tools/running-localstack/lstk/snapshots.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,11 @@ tags: ['Hobby']
9
9
10
10
Manage emulator snapshots.
11
11
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`.
13
13
14
14
:::note
15
15
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.`
18
17
:::
19
18
20
19
## `snapshot save`
@@ -50,6 +49,8 @@ The optional `[destination]` argument takes one of these forms:
50
49
51
50
Pod operations require an auth token (`LOCALSTACK_AUTH_TOKEN` or a prior `lstk login`); local-file snapshots do not.
52
51
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
+
53
54
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.
54
55
55
56
| Option | Description |
@@ -66,9 +67,12 @@ Load a snapshot into the emulator, **auto-starting it first** if it is not alrea
66
67
lstk snapshot load my-baseline
67
68
lstk snapshot load ./checkpoint
68
69
69
-
# Load from a Cloud Pod (requires auth)
70
+
# Load from a Cloud Pod (requires auth; latest version)
70
71
lstk snapshot load pod:my-baseline
71
72
73
+
# Load a specific version of a Cloud Pod
74
+
lstk snapshot load pod:my-baseline:3
75
+
72
76
# Load from your own S3 bucket (pod name is required)
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.
83
88
To load from S3, pass the pod name followed by an `s3://bucket/prefix` location (see [S3 remotes](#s3-remotes)).
84
89
85
90
| Option | Description |
@@ -154,10 +159,29 @@ Show metadata for a single Cloud Pod snapshot on the LocalStack platform: its na
154
159
This subcommand is cloud-only and requires authentication.
155
160
156
161
```bash
162
+
# Latest version
157
163
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
158
180
```
159
181
160
182
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`.
0 commit comments