I need to test my functions locally using AWS Web Socket API Gateway. Is there any possible way to mimic or duplicate the behaviour of AWS Web Socket in my local machine ? So I don't need to deploy every little changes to my Lambda function
Thanks
In API Gateway you can create a WebSocket API as a stateful frontend for an AWS service (such as Lambda or DynamoDB) or for an HTTP endpoint. The WebSocket API invokes your backend based on the content of the messages it receives from client apps.
In order to create the WebSocket API, we need first go to Amazon API Gateway service using the console. In there choose to create new API. Click on WebSocket to create a WebSocket API, give an API name and our Route Selection Expression. In our case add $request.
To create a WebSocket API using the API Gateway consoleSign in to the API Gateway console and choose Create API. Under WebSocket API, choose Build. Under Settings, in the API name field, enter the name of your API, for example, PetStore . Enter a Route Selection Expression for your API, for example, $request.
Unfortunately we're still waiting on local sam support for v2 of API Gateway.
https://github.com/awslabs/aws-sam-cli/issues/896
Recently I was able to find here that there is a workaround available called aws-lambda-ws-server which wraps the routes with a websocket server when ran locally and also works deployed as a AWS Lambda.
Hopefully this will help others in the future!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With