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
-
|`--non-interactive`| Disable the interactive TUI, use plain output |
16
-
|`--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
-
|`--persist`| Persist emulator state across restarts (on `start`/bare `lstk` and `restart`) |
18
-
|`--type <type>`, `-t <type>`| Emulator type to start: `aws`, `snowflake`, or `azure` (on `start`/bare `lstk`; records the choice in config). See [Selecting the emulator with `--type`](/aws/developer-tools/running-localstack/lstk/lifecycle-commands/#selecting-the-emulator-with---type). |
19
-
|`--snapshot <REF>`| Snapshot REF to auto-load after start (on `start`/bare `lstk`; overrides config for one run) |
20
-
|`--no-snapshot`| Skip auto-loading the configured snapshot (on `start`/bare `lstk`) |
21
-
|`--timeout <duration>`| Startup readiness deadline for `start`/bare `lstk`, as a Go duration; overrides `LSTK_STARTUP_TIMEOUT` for one run. See [`start`](/aws/developer-tools/running-localstack/lstk/lifecycle-commands/#start). |
22
-
|`-v`, `--version`| Print the version and exit |
23
-
|`-h`, `--help`| Print help and exit |
24
-
25
8
## Interactive and non-interactive mode
26
9
27
10
`lstk` automatically selects its output mode:
@@ -42,10 +25,32 @@ Commands that mutate state without prompting in CI (`reset`, `volume clear`) req
42
25
`lstk setup aws` works non-interactively — it writes the profile with defaults and needs `--force` only to overwrite a conflicting `localstack` profile.
43
26
:::
44
27
28
+
## Targeting an external emulator
29
+
30
+
By default `lstk` discovers the emulator it manages through local Docker.
31
+
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.
32
+
33
+
```bash
34
+
# Run against an emulator reachable at a custom URL
35
+
lstk aws --endpoint-url http://localhost:4566 s3 ls
36
+
37
+
# Equivalent via the environment
38
+
LSTK_ENDPOINT_URL=https://my-ephemeral-instance.localstack.cloud lstk status
39
+
```
40
+
41
+
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).
42
+
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.
43
+
44
+
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://…`.
45
+
46
+
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`.
47
+
48
+
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.
49
+
45
50
## Structured output
46
51
47
52
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.
48
-
JSON support is available per command: `stop`, `reset`, and `update` accept `--json`.
53
+
JSON support is available per command: `start`, `stop`, `status`, `reset`, and `update` accept `--json`.
49
54
Any other command rejects it with an error envelope (`error.code: NOT_JSON_CAPABLE`) rather than silently printing plain text.
50
55
51
56
Every JSON-capable command writes **exactly one** JSON object with the following envelope shape:
@@ -115,7 +120,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. |
123
+
|`LOCALSTACK_AUTH_TOKEN`| Auth token for non-interactive runs or to skip browser login. Takes precedence over a token stored in the keyring. |
124
+
|`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
125
|`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
126
|`LOCALSTACK_DISABLE_EVENTS`| Set to `1` to disable anonymous telemetry event reporting. |
121
127
|`DOCKER_HOST`| Override the Docker daemon socket (e.g. `unix:///home/user/.colima/default/docker.sock`). |
@@ -127,10 +133,20 @@ The following environment variables configure `lstk` itself (not the LocalStack
127
133
|`LSTK_API_ENDPOINT`| Override the LocalStack platform API base URL. Default: `https://api.localstack.cloud`. |
128
134
|`LSTK_WEB_APP_URL`| Override the LocalStack Web Application URL used for browser login. Default: `https://app.localstack.cloud`. |
129
135
130
-
When `DOCKER_HOST` is not set, `lstk` tries the default Docker socket and then probes common alternatives (Colima at `~/.colima/default/docker.sock` or `~/.config/colima/default/docker.sock`, OrbStack at `~/.orbstack/run/docker.sock`).
131
-
132
136
When `LSTK_OTEL` is enabled, the standard `OTEL_EXPORTER_OTLP_*` environment variables are honored by the OpenTelemetry SDK.
133
137
138
+
### Container runtime discovery
139
+
140
+
`lstk` talks to a Docker-compatible runtime and works with Docker Desktop, Rancher Desktop, Colima, OrbStack, Lima, and Podman. When `DOCKER_HOST` is not set, it resolves the daemon endpoint in this order:
141
+
142
+
1.**`DOCKER_HOST`**, if set, always wins.
143
+
2.**`DOCKER_CONTEXT`** or the active Docker CLI context, when it is non-default and reachable (a stale or unreachable context is skipped rather than failing).
144
+
3. On **Linux**, a live `/var/run/docker.sock` — a running Docker daemon is preferred over a co-installed runtime such as Podman.
145
+
4. A probe of known runtime sockets (Docker Desktop, Rancher Desktop, Colima, OrbStack, Podman, Lima). Each candidate is dialed, not just checked for existence, so a leftover socket file never shadows a live daemon.
146
+
5. The Docker SDK's own default.
147
+
148
+
If no runtime is reachable, the error tailors its suggested start command (`rdctl start`, `colima start`, `podman machine start`, …) to the runtime it detects. Set `DOCKER_HOST` to point at a specific socket to bypass discovery entirely.
149
+
134
150
### Container-injected variables
135
151
136
152
`lstk` injects several environment variables into the LocalStack container on every start, in addition to any profiles you configure:
Copy file name to clipboardExpand all lines: src/content/docs/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands.md
+17-1Lines changed: 17 additions & 1 deletion
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 immediately after `lstk aws`, before the AWS CLI's own action. 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,13 +64,27 @@ 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 immediately after `lstk aws`, before the AWS CLI's own action (placing it before `lstk aws` is a placement error; placing it after the action is not caught — `lstk` silently forwards it to the `aws` CLI, which then rejects it). 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.
68
84
`lstk az` runs `az` with an isolated `AZURE_CONFIG_DIR` in which a custom Azure cloud is registered against LocalStack's endpoints, so your global `~/.azure` configuration is left untouched and plain `az` keeps talking to real Azure.
69
85
70
86
Run [`lstk setup azure`](/aws/developer-tools/running-localstack/lstk/setup-and-maintenance/#setup-azure) once before using this mode.
71
-
Everything after `lstk az` is forwarded verbatim to the host `az` binary, and its exit code and output are passed through unchanged.
87
+
Arguments are forwarded to the host `az` binary, and its exit code and output are passed through unchanged. `lstk`'s own flags (`--non-interactive`, `--config`) are consumed by `lstk` rather than forwarded — for example `lstk az --non-interactive …` suppresses the loading spinner instead of passing the flag to `az`.
# 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). |
0 commit comments