Automated Spot Instance Cost Monitor for Game Servers
Hosting dedicated multiplayer game servers (like Factorio or Terraria) on AWS can become expensive if running 24/7 on On-Demand EC2 instances. AWS Spot Instances offer up to a 90% discount, but prices fluctuate based on capacity. This microservice automatically monitors those fluctuations and alerts users when high-compute instances drop below a target price.
The Architecture Flow
[ EventBridge (Cron) ] → [ AWS Lambda ] ←→ [ AWS Pricing API ]
↓
[ Amazon SNS ]
↙ ↘
[ Email Alert ] [ Webhook (Discord) ]
1. The Scheduled Trigger
An Amazon EventBridge rule is configured as a Cron job, firing every hour. This is vastly more cost-effective than running a persistent script on an Unraid server or EC2 instance.
2. Logic & Evaluation
The EventBridge rule triggers a Python Lambda function. The function uses the boto3 SDK to call the DescribeSpotPriceHistory API, fetching the current Spot prices for specific instance types (e.g., t3.large or c5.large) in specific Availability Zones. The script compares the retrieved price against a DynamoDB table containing user-defined threshold limits.
3. Pub/Sub Alerting
If the Spot price falls below the threshold, the Lambda function publishes a message to an Amazon SNS (Simple Notification Service) topic. SNS then fans out the message to all subscribed endpoints, simultaneously sending an email to the administrator and a JSON payload to a Discord webhook to notify the gaming group that the server is ready to spin up cheaply.
This entire monitoring stack falls entirely within the AWS Free Tier, meaning it costs $0.00 a month to operate while potentially saving hundreds of dollars in compute costs.