WireMock on LocalStack
This repo contains a LocalStack Extension that facilitates developing WireMock-based applications locally.
The extension supports two modes:
- OSS WireMock: Uses the open-source
wiremock/wiremockimage (default) - WireMock Runner: Uses
wiremock/wiremock-runnerwith WireMock Cloud integration (requires API token)
Prerequisites
- Docker
- LocalStack Pro (free trial available)
localstackCLImake- WireMock CLI (for WireMock Runner mode)
Install from GitHub repository
This extension can be installed directly from this Github repo via:
localstack extensions install "git+https://github.com/localstack/localstack-extensions.git#egg=localstack-wiremock&subdirectory=wiremock"
Install local development version
To install the extension into LocalStack in developer mode, you will need Python 3.11, and create a virtual environment in the extensions project.
In the newly generated project, simply run
make install
Then, to enable the extension for LocalStack, run
localstack extensions dev enable .
You can then start LocalStack with EXTENSION_DEV_MODE=1 to load all enabled extensions:
EXTENSION_DEV_MODE=1 localstack start
Usage
OSS WireMock Mode (Default)
Start LocalStack without any special configuration:
localstack start
The WireMock server will be available at http://wiremock.localhost.localstack.cloud:4566.
You can import stubs using the WireMock Admin API (assuming a stubs.json exists in the local working directory):
curl -X POST -H "Content-Type: application/json" \
--data-binary "@stubs.json" \
"http://wiremock.localhost.localstack.cloud:4566/__admin/mappings/import"
WireMock Runner Mode (Cloud Integration)
To use WireMock Runner with WireMock Cloud, you need:
- A WireMock Cloud API token
- A
.wiremockdirectory with your mock API configuration
Step 1: Get your WireMock Cloud API Token
- Sign up at WireMock Cloud
- Go to Settings → API Tokens
- Create a new token
Step 2: Create your Mock API configuration
First, create a Mock API in WireMock Cloud, then pull the configuration locally:
# Install WireMock CLI if not already installed
npm install -g @wiremock/cli
# Login with your API token
wiremock login
# Pull your Mock API configuration
# Find your Mock API ID from the WireMock Cloud URL (e.g., https://app.wiremock.cloud/mock-apis/zwg1l/...)
wiremock pull mock-api <mock-api-id>
This creates a .wiremock directory with your wiremock.yaml configuration.
Step 3: Start LocalStack with WireMock Runner
LOCALSTACK_WIREMOCK_API_TOKEN="your-api-token" \
LOCALSTACK_WIREMOCK_CONFIG_DIR="/path/to/your/project" \
localstack start
Environment Variables:
WIREMOCK_API_TOKEN: Your WireMock Cloud API token (required for runner mode)WIREMOCK_CONFIG_DIR: Path to the directory containing your.wiremockfolder (required for runner mode)WIREMOCK_IMAGE: Custom Docker image name for the Wiremock OSS image (default:wiremock/wiremock)WIREMOCK_IMAGE_RUNNER: Custom Docker image name for the Wiremock Cloud runner image (default:wiremock/wiremock-runner)
Note: When using the LocalStack CLI, prefix environment variables with LOCALSTACK_ to forward them to the container.
Sample Application
See the sample-app-runner/ directory for a complete example using Terraform that demonstrates:
- Creating an API Gateway
- Lambda function that calls WireMock stubs
- Integration testing with mocked external APIs
Change Log
0.1.1: Add environment variables to customize the WireMock image names0.1.0: Initial release of the extension
License
This project is licensed under the Apache License, Version 2.0.
Release files for localstack-wiremock 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| localstack_wiremock-0.1.1.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| localstack_wiremock-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.4 kB
Release files / localstack_wiremock-0.1.1.tar.gz
| Download URL | localstack_wiremock-0.1.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2717ea5735fce05110aa0020820e2b42c478312884af7b0a2d3937b5a73c76cb
|
|
BLAKE2b-256 checksum How to use checksums |
c310419bdd324cbc4ed3f4fae297f633876e87cd60e5b2f44b4b596cc13e2b39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / localstack_wiremock-0.1.1-py3-none-any.whl
| Download URL | localstack_wiremock-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd076ceb2c289b8bf6c0b4b02be542742cf157000a4b9cdea4fe00d206a18e67
|
|
BLAKE2b-256 checksum How to use checksums |
a8e82bbbc721b5f173eef577119f8b108e5e0040bff933dbc24afdaff577c4dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|