| Key | Value |
|---|---|
| Services | API Gateway, Lambda |
| Integrations | Serverless Framework |
| Categories | Serverless; WebSockets |
A demo application illustrating API Gateway V2 WebSocket APIs using LocalStack, deployed via the Serverless framework. The sample deploys a Lambda function connected to a WebSocket API and demonstrates bidirectional message passing over the WebSocket connection.
- A valid LocalStack for AWS license. Your license provides a
LOCALSTACK_AUTH_TOKENto activate LocalStack. - Docker
localstackCLI- Node.js with
npm - Serverless Framework
make checkmake installexport LOCALSTACK_AUTH_TOKEN=<your-auth-token>
make startmake runThe script deploys the WebSocket API via Serverless, connects a WebSocket client, sends a test message, and verifies it is echoed back by the Lambda handler.
You should see output similar to:
...
Serverless: Stack create finished...
...
Starting client that connects to Websocket API
Sending message to websocket
Received message from websocket: {"action":"test-action"}
This code is available under the Apache 2.0 license.