This Terraform code creates a WebSocket API in AWS API Gateway.
- You can use the client of your choice. Consider using wscat.
- Configure an AWS API gateway endpoint which maintains a WebSocket to the client
- A Lambda connected to the API gateway endpoint which responds to requests sent to the API gateway
- A DynamoDB collection which contains a set of random words
[{ “word”: “car“}, {“word“: “truck“}, {“word“: “banana“}]
- Install wscat (npm install -g wscat).
- Establish a WebSocket connection to the WebSocket API.
wscat -c wss_api_connection_url
- Send a message to the API Gateway endpoint (randomword) that triggers the Lambda to read a random word out of the DynamoDB table.
{"action": "randomword"}
- The Lambda should return the random word to the API Gateway which should return it to the client which should display it on the screen.