Backend serverless IaC on AWS to remotely control my Philips Hue bulbs whenever my favorite sports teams score or win. Written in Swift and deployed via Swift Cloud.
Read the blog post about it here.
It currently consists of six primary pieces of infrastructure, all defined within Infra/Project.swift
:
- A cron job managed by EventBridge that triggers my scheduler function
- A scheduler Lambda function that fires off SQS events every 10 seconds
- An SQS queue to hold those events
- A poller Lambda function triggered by SQS that polls the ncaa-api for Tulsa football, men’s basketball, and women’s basketball scores, and the public-espn-api for Eagles scores. It writes those results to DynamoDB
- A DynamoDB table that keeps track of the games found in the previous step
- A processor Lambda function triggered by DynamoDB Streams that checks the scores for those teams I care about, and if they scored (football only) or won, make my Philips Hue lights go nuts in that team’s colors
It also consists of two other pieces of infrastructure used to refresh my Hue API tokens every 3 days:
- A cron job managed by EventBridge that triggers my token refresher function
- A token refresher Lambda function that refreshes my Hue API tokens