Skip to content

Add --endpoint-url flag to target externally-managed emulators - #419

Draft
peter-smith-phd wants to merge 4 commits into
mainfrom
devx-1025-allow-arbitrary-end-points
Draft

Add --endpoint-url flag to target externally-managed emulators#419
peter-smith-phd wants to merge 4 commits into
mainfrom
devx-1025-allow-arbitrary-end-points

Conversation

@peter-smith-phd

Copy link
Copy Markdown
Contributor

Summary

  • Adds a global --endpoint-url <url> flag (plus LSTK_ENDPOINT_URL/AWS_ENDPOINT_URL env vars) so aws, az, terraform/tf, cdk, sam, snapshot save/load/remove/list s3://..., reset, and status can target an emulator lstk didn't start — docker compose, host-network mode, CI, or a remote machine — instead of discovering one via local Docker.
  • Emulator type (aws/azure/snowflake) is auto-detected by probing /_localstack/health (falling back to /_localstack/info for Azure); there's no manual override — an inconclusive result is a hard failure.
  • logs/stop/restart/volume reject an explicit --endpoint-url (no remote equivalent, and silently ignoring it risks acting on the wrong local target); snapshot show/bare snapshot list silently ignore it (platform-only, no emulator involved either way).
  • --endpoint-url is recognized only when it precedes the subcommand name for the five DisableFlagParsing proxy commands, matching --json's existing treatment — required because the aws CLI has its own native --endpoint-url flag that must still reach it untouched when placed after aws.
  • BREAKING: terraform/cdk/sam previously required a locally Docker-discovered AWS container even when AWS_ENDPOINT_URL was set (it only relabeled the generated endpoint value). AWS_ENDPOINT_URL alone now also skips that Docker discovery, consistent with --endpoint-url/LSTK_ENDPOINT_URL.

Full design/spec: openspec/changes/add-endpoint-url-flag/.

Review

Advised. This is a large, cross-cutting change (new package, 12+ command files rewired, one breaking-change behavior) with several non-obvious design calls — the pre-command-only flag placement rule, the runtime.NewExternalRuntime stub used to reuse existing Docker-shaped discovery code, and the reject-vs-silently-ignore split for commands that don't support the flag. Worth a careful pass before merging.

One caveat: the AWS-vs-Snowflake detection heuristic (inspecting the /_localstack/health services map) was confirmed against a real AWS community image but not against Snowflake, which requires a licensed emulator I didn't have access to — see design.md's Open Questions.

Test plan

  • go build ./..., go vet ./..., full unit suite (1194 passed)
  • New unit tests: internal/endpoint/target_test.go (precedence, URL validation, health/type probe classification), internal/runtime/external_test.go
  • New integration tests: test/integration/endpoint_url_test.go (Docker-bypass, aws-CLI flag-collision fix, reject/ignore split, wrong-type detection, AWS_ENDPOINT_URL breaking-change bypass)
  • Ran existing aws/cdk/sam/terraform/az/snapshot integration suite for regressions (211 passed; the 2 remaining failures were confirmed present on the unmodified base branch too — pre-existing environmental flakiness, unrelated to this change)
  • golangci-lint (newer local version than pinned; only findings are in an untouched file) and govulncheck clean

Closes DEVX-1025

Co-Authored-By: Claude noreply@anthropic.com

peter-smith-phd and others added 2 commits July 30, 2026 09:47
Proposes letting aws/az/terraform/cdk/sam/snapshot/reset/status target
an externally-managed emulator (docker compose, host mode, remote) via
--endpoint-url/LSTK_ENDPOINT_URL/AWS_ENDPOINT_URL, bypassing local Docker
discovery in favor of an HTTP health-based reachability and type probe.

Co-Authored-By: Claude <noreply@anthropic.com>
Lets aws/az/terraform/cdk/sam/snapshot/reset/status target an emulator
lstk didn't start (docker compose, host-network mode, a remote machine)
via --endpoint-url/LSTK_ENDPOINT_URL/AWS_ENDPOINT_URL, bypassing local
Docker discovery in favor of an HTTP-based reachability and type probe.

BREAKING: terraform/cdk/sam previously required a locally Docker-discovered
AWS container even when AWS_ENDPOINT_URL was set (it only relabeled the
generated endpoint value). AWS_ENDPOINT_URL alone now also skips that
Docker discovery, consistent with the other two sources.

Co-Authored-By: Claude <noreply@anthropic.com>
@peter-smith-phd peter-smith-phd added semver: major docs: needed Pull request requires documentation updates labels Jul 29, 2026
Picks up #399 (Podman/Rancher Desktop runtime detection), which added
Flavor() and InspectBrief() to the Runtime interface. Implements both
on the externalRuntime stub added by this branch: Flavor reports
FlavorUnknown (no real daemon behind an externally-managed emulator),
InspectBrief mirrors IsRunning's exact-name-match logic.

Co-Authored-By: Claude <noreply@anthropic.com>
…ecycle commands

Preserves the resolved scheme end-to-end for --endpoint-url targets (needed
for LocalStack's cloud-hosted ephemeral instances) and fixes three bugs:
status omitted resources for external targets, start silently accepted and
ignored --endpoint-url, and logs/stop/restart/volume/start only rejected an
explicit flag while silently proceeding against the local emulator when
LSTK_ENDPOINT_URL/AWS_ENDPOINT_URL was set ambiently.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs: needed Pull request requires documentation updates semver: minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant