Skip to content

Commit e015f98

Browse files
gtsiolisclaudeanisaoshafiquetzalliwrites
authored
docs(lstk hotfix): update CLI reference to v1.0.0 (#912)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Anisa Oshafi <anisaoshafi@gmail.com> Co-authored-by: Quetzalli <alejandra.olvera.novack@gmail.com>
1 parent 8149e81 commit e015f98

10 files changed

Lines changed: 244 additions & 89 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: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
11
---
22
title: lstk Automation & CI
3-
description: Global options, non-interactive mode, structured JSON output, environment variables, tracing, and logging for scripting lstk.
3+
description: Non-interactive mode, structured JSON output, targeting an external emulator, environment variables, tracing, and logging for scripting lstk.
44
template: doc
55
tags: ['Hobby']
66
---
77

8-
## Global options
9-
10-
These options are available for all commands:
11-
12-
| Option | Description |
13-
|:--------------------|:------------------------------------------------------------------------------|
14-
| `--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-
258
## Interactive and non-interactive mode
269

2710
`lstk` automatically selects its output mode:
@@ -42,10 +25,32 @@ Commands that mutate state without prompting in CI (`reset`, `volume clear`) req
4225
`lstk setup aws` works non-interactively — it writes the profile with defaults and needs `--force` only to overwrite a conflicting `localstack` profile.
4326
:::
4427

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+
4550
## Structured output
4651

4752
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`.
4954
Any other command rejects it with an error envelope (`error.code: NOT_JSON_CAPABLE`) rather than silently printing plain text.
5055

5156
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
115120

116121
| Variable | Description |
117122
|:-------------------------------|:---------------------------------------------------------------------------------------------------------------------|
118-
| `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). |
119125
| `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. |
120126
| `LOCALSTACK_DISABLE_EVENTS` | Set to `1` to disable anonymous telemetry event reporting. |
121127
| `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
127133
| `LSTK_API_ENDPOINT` | Override the LocalStack platform API base URL. Default: `https://api.localstack.cloud`. |
128134
| `LSTK_WEB_APP_URL` | Override the LocalStack Web Application URL used for browser login. Default: `https://app.localstack.cloud`. |
129135

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-
132136
When `LSTK_OTEL` is enabled, the standard `OTEL_EXPORTER_OTLP_*` environment variables are honored by the OpenTelemetry SDK.
133137

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+
134150
### Container-injected variables
135151

136152
`lstk` injects several environment variables into the LocalStack container on every start, in addition to any profiles you configure:

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

Lines changed: 17 additions & 1 deletion
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 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). |
4345
| `--non-interactive` | Suppress the loading spinner. Unlike other commands, this flag is stripped before invoking `aws` (not forwarded). |
4446

4547
:::note
@@ -62,13 +64,27 @@ 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 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+
6581
## `az`
6682

6783
Run Azure CLI commands against the running LocalStack Azure emulator.
6884
`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.
6985

7086
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`.
7288

7389
```bash
7490
lstk az group list

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). |

0 commit comments

Comments
 (0)