This example demonstrates how to setup a websocket API with API Gateway and AWS Lambda.
The API has a single route $default that accepts a request and echos it back in the response.
All the infrastructure for this example is managed by Pulumi.
You will need to download and install the Pulumi CLI. Once installed, you will need to configure Pulumi to use your AWS account.
Clone this repo and from this working directory run:
$ pulumi up
This will deploy the changes and output the URL for the created API Gateway. It will look something like this:
Outputs:
url: "wss://<YOUR_API_GATEWAY_URL_HERE>.execute-api.us-east-1.amazonaws.com/dev"
You can use a tool like wscat to test the API. Run the following command to connect to the API:
$ wscat -c wss://<YOUR_API_GATEWAY_URL_HERE>.execute-api.us-east-1.amazonaws.com/dev