Janky Werewolf
2020-12-22
Janky Werewolf is a way to play the "secret roles" game Werewolf, online with friends. I made some contributions to the front-end (typescript with React) but primarily I wrote the backend game logic and state synchronisation.
The system is written in Rust to run on AWS Lambda using an event driven pattern. Clients connect a websocket over API Gateway, post messages to an API lambda which writes to a DynamoDB table. Dynamo Streams passes the new state on to another lambda which returns a filtered version to the players back over the API Gateway websocket.
The game is built and deployed from Github Actions because it was quick to setup, efficient to run and falls well within the Github tier I was already subscribed to. Terraform is used to deploy the infrastructure because it can provide a consistent automated environment setup. In combination with Github Actions it can deploy a fresh environment for each code branch pushed.
Rust on Lambda is still a young and immature ecosystem and as a result there are some issue with the codebase which cannot yet be resolved. For example to take advantage of Rust features like Async an (as yet) unreleased version of the Lambda runtime must be used. Additionally the events the lambda receives from AWS are not yet reliably available in a package so must be directly included in the codebase.