Add Mockoon extension - #172
Merged
Merged
Conversation
Add a new LocalStack extension that runs the Mockoon CLI next to LocalStack and serves mock APIs under mockoon.localhost.localstack.cloud:4566. Includes integration tests, a Terraform sample app, and a CI workflow, modeled after the WireMock extension. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Commands for testing this directly from the branch, no checkout needed (requires Note: installing via # 1. Install the extension from the branch
localstack extensions install 'localstack-mockoon @ https://github.com/localstack/localstack-extensions/archive/refs/heads/add-mockoon-extension.tar.gz#subdirectory=mockoon'
# 2. Start LocalStack; Mockoon loads the sample environment from the branch via URL
# (stop a running instance first: env vars only apply at startup)
localstack stop
LOCALSTACK_MOCKOON_DATA="https://raw.githubusercontent.com/localstack/localstack-extensions/add-mockoon-extension/mockoon/sample-app/environment.json" \
localstack start -d
localstack wait -t 120
# 3. Mock routes
curl -s http://mockoon.localhost.localstack.cloud:4566/orders/42 # templated: "id": "42", status shipped
curl -s -i http://mockoon.localhost.localstack.cloud:4566/orders/unknown # response rule: 404 "Order not found"
curl -s -X POST -H "Content-Type: application/json" -d '{"sku":"SKU-42"}' \
http://mockoon.localhost.localstack.cloud:4566/orders # 201, echoes "sku": "SKU-42"
# 4. Admin API (default token: test)
curl -s -o /dev/null -w "%{http_code}\n" http://mockoon.localhost.localstack.cloud:4566/mockoon-admin/logs # 401
curl -s -H "Authorization: Bearer test" http://mockoon.localhost.localstack.cloud:4566/mockoon-admin/logs # transaction logs
# 5. Optional: default mode (no MOCKOON_DATA)
localstack stop
localstack start -d && localstack wait -t 120
curl -s http://mockoon.localhost.localstack.cloud:4566/welcome
# 6. Optional: hot reload with a local file (path must be absolute, edit the file in place)
localstack stop
curl -sO https://raw.githubusercontent.com/localstack/localstack-extensions/add-mockoon-extension/mockoon/sample-app/environment.json
LOCALSTACK_MOCKOON_DATA="$PWD/environment.json" localstack start -d && localstack wait -t 120
curl -s http://mockoon.localhost.localstack.cloud:4566/orders/42 # edit environment.json, re-run: changes appear after ~2s
# 7. Clean up
localstack stop
localstack extensions uninstall localstack-mockoon |
Install the pinned lstk release (checksum-verified) instead of the localstack, terraform-local and awscli-local pip packages. The built extension is mounted into the container and installed at startup via EXTENSION_AUTO_INSTALL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Avoid parsing aws CLI output via lstk aws, which emitted non-JSON output in CI and broke the jq lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- install lstk in CI via npm (pinned version), as recommended by the docs - README: use lstk, and install the extension via EXTENSION_AUTO_INSTALL (dev mode still requires the legacy localstack CLI) - sample app deploys via `lstk terraform` by default - pin the default image to mockoon/cli:9 (relies on v9 CLI flags and admin API) - fail fast on relative MOCKOON_DATA paths Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
purcell
approved these changes
Sep 30, 2026
purcell
left a comment
Collaborator
There was a problem hiding this comment.
I looked through this and tested it out locally, so it's good to go. Ideally we'd use the regular CLI rather than lstk with LOCALSTACK_EXTENSION_AUTO_INSTALL: it introduces yet another pattern in the extension workflows, and the README tells the user to use the former anyway. That's not a blocker though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new extension that runs Mockoon (
mockoon/cliimage) next to LocalStack, serving mock APIs underhttp://mockoon.localhost.localstack.cloud:4566. The setup follows the layout of other extensions in the repo: Makefile targets, CI workflow, and a Terraform sample app (API Gateway + Lambda calling a mocked Orders API)./cc @HarshCasper @remotesynth @255kb
How mocks are loaded
Mockoon's admin API can update responses at runtime but can't add routes, so mocks get loaded at container start via
MOCKOON_DATA:cloud://<id>(withMOCKOON_CLOUD_TOKEN)GET /welcomerouteThe admin API is proxied at
/mockoon-admin, with bearer tokenMOCKOON_ADMIN_API_TOKEN(defaulttest). The default image is pinned tomockoon/cli:9(the extension relies on the v9 CLI flags and admin API), andMOCKOON_IMAGEoverrides it. RelativeMOCKOON_DATApaths are rejected at startup, since Docker would otherwise mount an empty directory.Testing
make test: integration tests for templating, response rules, admin API auth, logs, global vars, and runtime environment updatesmake sample: deploys the sample app and checks the Lambda responselstkCLI (installed via npm, pinned): the built extension is mounted into the container and installed at startup viaEXTENSION_AUTO_INSTALL, LocalStack is started withLOCALSTACK_MOCKOON_DATApointing tosample-app/environment.json, and the sample app is deployed vialstk terraformAll passed in CI (
latestanddevimages).Notes
/aren't forwarded by the sharedProxyResourcein utils (route is/<path:path>), which is why the default route is/welcome. Left utils untouched here.lstk. Aslstkhas no extension commands, the extension is installed viaEXTENSION_AUTO_INSTALL; developer mode still requires the legacylocalstackCLI (it mounts the extension sources into the container).馃 Generated with Claude Code