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>
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 |
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 WireMock extension: same Makefile targets, CI workflow, and a Terraform sample app (API Gateway + Lambda calling a mocked Orders API).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).MOCKOON_IMAGEoverrides the image.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 responseLOCALSTACK_MOCKOON_DATApointing tosample-app/environment.json, then runs bothAll passed locally against LocalStack Pro.
Notes
/aren't forwarded by the sharedProxyResourcein utils (route is/<path:path>), which is why the default route is/welcome. Left utils untouched here.localstack-mockoonto matchlocalstack-wiremock.馃 Generated with Claude Code