| Crates.io | aoc_leaderbot_aws_lambda_impl |
| lib.rs | aoc_leaderbot_aws_lambda_impl |
| version | 2.0.0 |
| created_at | 2025-11-27 02:51:28.805737+00 |
| updated_at | 2025-11-28 06:34:21.753216+00 |
| description | Implementation of an Advent of Code leaderboard-watching bot running in AWS Lambda |
| homepage | https://github.com/clechasseur/aoc_leaderbot/tree/main/aoc_leaderbot_aws_lambda_impl#readme |
| repository | https://github.com/clechasseur/aoc_leaderbot |
| max_upload_size | |
| id | 1952983 |
| size | 166,682 |
Implementation of aoc_leaderbot that runs as an AWS Lambda function.
aoc_leaderbot is a bot that can watch an Advent of Code private leaderboard for changes and report them to various channels.
Installing aoc_leaderbot_aws_lambda_impl requires building the project, deploying it to your AWS account and setting up permissions and (optionally) scheduling its execution.
Before deploying, make sure your environment contains credentials to access your AWS account; for more information, see this page.
This implementation of aoc_leaderbot uses serverless AWS services like Lambda and DynamoDB because at the time of this writing, those services were included in the AWS Free Tier.
In theory, running the bot every 15 minutes continuously should be well below service limits of the Free Tier. Please note however that this is not guaranteed as AWS costs can be affected by many things and change change over time. Before deploying the bot, make sure you are aware of possible hosting costs.
Create a file named .env at the project root and populate it with environment variables to configure the bot.
| Variable name | Content | Required? | Default value |
|---|---|---|---|
AOC_LEADERBOT_AWS_YEAR |
Year to monitor | ✓ | Current year |
AOC_LEADERBOT_AWS_LEADERBOARD_ID |
ID of leaderboard to monitor 1 | ✓ | - |
AOC_LEADERBOT_AWS_VIEW_KEY |
View key to access leaderboard's read-only link 2 | ✓ 3 | - |
AOC_LEADERBOT_AWS_SESSION_COOKIE |
Cookie of Advent of Code session to access the leaderboard | ✓ 3 | - |
SLACK_WEBHOOK_URL |
URL of Slack webhook where to report changes | ✓ | - |
SLACK_CHANNEL |
Slack channel where to report changes (without the #) |
✓ | - |
SLACK_LEADERBOARD_SORT_ORDER |
How to sort leaderboard members when reporting (see LeaderboardSortOrder) |
Stars |
1 : The leaderboard ID is the last part of the leaderboard's URL: https://adventofcode.com/{year}/leaderboard/private/view/{leaderboard_id}.
2 : If the leaderboard is accessible anonymously through a read-only link, the view key is passed as a query parameter: https://adventofcode.com/{year}/leaderboard/private/view/{leaderboard_id}?view_key={view_key}
3 : Either the VIEW_KEY or the SESSION_COOKIE must be set. If both are set, the VIEW_KEY is used.
The bot stores leaderboard data in a DynamoDB table between runs. Before running the bot for the first time, create the table by running:
just prepare-dynamo
This will make sure that the table is created with the proper hash and range key configuration.
Build the Lambda function package so that it's ready for deployment by running:
just release=true build-lambda
Be patient as this can take a while the first time.
Once the Lambda function package is built, it can be deployed by running:
just deploy-lambda
Once the Lambda function is deployed, it needs to be given permission to read and write to the DynamoDB table. This can be done by editing the IAM role that has been created when the Lambda function was deployed. There are different ways of doing this; to do it via the AWS Management console:
GetItemPutItemDescribeTableaoc_leaderbot.Please note that the AWS Management console might evolve over time and that the instructions above might become obsolete in the future; if in doubt, read the official documentation. It is also possible to attach these permissions to the role programmatically or via the AWS CLI.
Up to now, the bot should be functional - you can test it by invoking the bot's Lambda function with a test event (an empty payload should do if all the environment variables were correctly set in you .env file prior to deploying the bot).
If you want to run the bot on a schedule, you can add a trigger to the bot's Lambda function.
Again, there are various possible trigger types; one is Amazon EventBridge.
Creating such a schedule is a bit outside the scope of this README, but you can peruse the EventBridge documentation for more information.
If ever a new version of the bot is released and you want to update your bot's Lambda function, you can simply build and deploy it again using the instructions above. This will deploy a new version of the Lambda function. (If the new version has breaking changes, be sure to read the instructions on how to upgrade before deployment.)
For information about contributing to this project, see CONTRIBUTING. For information regarding local development, see DEVELOPMENT.