Skip to content

chore(setup): replace LocalStack with moto-server for local SQS simulation#27

Open
prshant70 wants to merge 4 commits into
mainfrom
feat/moto-server-sqs-quicksetup
Open

chore(setup): replace LocalStack with moto-server for local SQS simulation#27
prshant70 wants to merge 4 commits into
mainfrom
feat/moto-server-sqs-quicksetup

Conversation

@prshant70

Copy link
Copy Markdown
Contributor

Closes #26

What

Replaces LocalStack with the credential-free motoserver/moto Docker image as the local SQS simulator used by python3 notify_setup.py. The four superproject setup scripts (notify_setup.py, gateway_setup.py, core_setup.py, handler_setup.py) are updated: LocalStack install/start logic is removed, a moto-server container is started on port 5000 with a readiness poll, and all queue-creation commands previously using docker exec awslocal are replaced with direct boto3 calls against http://localhost:5000.

Why

LocalStack now requires authentication (a license token), which blocks first-time contributors from completing quick-setup with no AWS account. motoserver/moto is a drop-in replacement that requires no credentials, ships multi-arch Docker images (amd64 + arm64), and exposes a compatible HTTP endpoint on port 5000.

How

  • notify_setup.py: deletes the LocalStack version-check/pip-install/start block; inserts docker rm --force moto-server, docker pull motoserver/moto, docker run -p 5000:5000 --detach --name moto-server, and a 30-retry stdlib urllib.request readiness poll. Updates the docker network connect call from localstack-main to moto-server. Adds import time and import urllib.request (stdlib only, no new dependencies).
  • gateway_setup.py, core_setup.py, handler_setup.py: add import boto3; update darwin/linux SQS endpoint URL strings from port 4566 / localstack-main to port 5000 / moto-server; replace docker exec awslocal queue-creation subprocess loops with boto3.client('sqs', endpoint_url='http://localhost:5000', ...) loops using inline dummy credentials (non-secret moto-server placeholders). The queue-creation endpoint is unconditionally http://localhost:5000 on both macOS and Linux because the scripts run on the host and the container publishes port 5000 via -p 5000:5000. The SQS_ENDPOINT_URL values written to each service's config.json remain http://moto-server:5000 on Linux for container-to-container routing.

Testing

No automated test suite exists for these setup scripts. Manual verification:

# Clean run on macOS (Apple Silicon) or Linux — no AWS account required
python3 notify_setup.py

# Verify queues were created
python3 - <<'PYEOF'
import boto3
sqs = boto3.client('sqs', endpoint_url='http://localhost:5000',
                   region_name='us-east-1',
                   aws_access_key_id='test', aws_secret_access_key='test')
print(sqs.list_queues())
PYEOF

# Confirm no localstack or 4566 references remain
grep -r localstack notify_setup.py gateway_setup.py core_setup.py handler_setup.py
grep -r 4566 notify_setup.py gateway_setup.py core_setup.py handler_setup.py

# Syntax check
python3 -m py_compile notify_setup.py gateway_setup.py core_setup.py handler_setup.py

Passing state: notify_setup.py completes to ##### Congratulations! NotifyOne system setup Completed #####, list_queues returns all expected queue names, both grep commands return no output, py_compile exits 0. Re-running a second time must not fail with "container name already in use".

Checklist

  • Tests pass (python3 -m py_compile notify_setup.py gateway_setup.py core_setup.py handler_setup.py)
  • No secrets committed (dummy credentials test/test are non-secret moto-server placeholders)
  • Manual verification: run python3 notify_setup.py on a clean machine with no AWS account and no LocalStack installed; confirm setup completes and list_queues returns expected queues; re-run a second time to confirm no "container name already in use" error

Prashant Mishra and others added 2 commits June 11, 2026 19:03
- Remove LocalStack version-check, pip install, and start block from notify_setup.py
- Add moto-server container start sequence (docker rm --force, pull motoserver/moto, docker run -p 5000:5000 --detach)
- Add urllib.request readiness poll (30 retries, 1s sleep) with exit(1) on timeout
- Replace docker network connect localstack-main with moto-server in notify_setup.py
- Replace port 4566 / localstack-main with port 5000 / moto-server in gateway_setup.py, core_setup.py, and handler_setup.py
- Replace docker exec awslocal queue-creation loops with inline boto3 sqs.create_queue calls in all three service setup scripts
- gateway_setup.py, core_setup.py, handler_setup.py: remove darwin/linux
  ternary from _sqs_endpoint; always use http://localhost:5000
- moto-server publishes -p 5000:5000 so localhost:5000 is reachable from
  the host on both macOS and Linux; 'moto-server' hostname is only valid
  inside the Docker network (container-to-container), not from the host
- config.json SQS_ENDPOINT_URL values (http://moto-server:5000 on Linux)
  are unchanged — they are correct for container-to-container use

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@prshant70
prshant70 requested a review from a team as a code owner June 11, 2026 13:42
@deputydev-agent

Copy link
Copy Markdown

DeputyDev will no longer review pull requests automatically.To request a review, simply comment #review on your pull request—this will trigger an on-demand review whenever you need it.

Prashant Mishra and others added 2 commits June 11, 2026 19:20
If something is already listening on localhost:5000 (e.g. a moto-server
started in a previous run), the script now detects it upfront and skips
the pull/rm/run sequence entirely instead of failing with a port-binding
error.

Also suppress stderr on `docker rm --force moto-server` so the expected
"No such container" message on a fresh run does not pollute output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Port 5000 is commonly occupied on macOS (AirPlay Receiver) and
potentially other services. Map the moto-server container's internal
port 5000 to host port 15000 via `-p 15000:5000`.

Updates all host-side references: readiness poll, boto3 queue-creation
endpoint, and macOS config.json SQS_ENDPOINT_URL. Container-to-container
URLs (http://moto-server:5000) are unchanged — that is the container's
internal port and is unaffected by the host port mapping.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace LocalStack with moto-server in quick setup (SQS simulation)

1 participant