This project is a real-time NBA game alert system that notifies subscribed users via SMS or email about live game scores. It uses AWS services like SNS, Lambda, and EventBridge, along with NBA APIs, to deliver up-to-date game information to basketball fans. The project highlights cloud computing concepts and efficient notification handling.
- Fetches live NBA game scores from an external API.
- Sends formatted score updates to subscribers via SMS/Email using Amazon SNS.
- Automates regular updates with Amazon EventBridge.
- Designed with security best practices, ensuring IAM roles follow the principle of least privilege.
- Cloud Provider: AWS
- Core Services: SNS, Lambda, EventBridge
- External API: NBA Game API (SportsData.io)
- Programming Language: Python 3.x
- IAM Security:
- Least privilege policies for Lambda, SNS, and EventBridge.
- Open the AWS Management Console and go to the SNS service.
- Click Create Topic and select Standard as the topic type.
- Enter a name for the topic (e.g.,
gameday_topic
) and note the ARN. - Click Create Topic to finalize.
- Open the SNS topic from the list.
- Navigate to the Subscriptions tab and click Create Subscription.
- Choose a protocol:
- For Email:
- Select Email and enter a valid email address.
- For SMS (phone number):
- Select SMS and enter a valid phone number in international format (e.g.,
+1234567890
).
- Select SMS and enter a valid phone number in international format (e.g.,
- For Email:
- Click Create Subscription.
- Confirm the Subscription:
- For Email: Check your inbox and click the confirmation link.
- For SMS: The subscription is active immediately after creation.
- Open the IAM service in the AWS Management Console.
- Go to Policies → Create Policy.
- Click JSON and paste the JSON policy from
gameday_sns_policy.json
. - Replace REGION and ACCOUNT_ID with your AWS details.
- Click Next: Tags (optional), then Next: Review.
- Enter a name for the policy (e.g.,
gameday_sns_policy
) and click Create Policy.
- Open the IAM service in the AWS Management Console.
- Navigate to Roles → Create Role.
- Select AWS Service and choose Lambda.
- Attach the following policies:
- SNS Publish Policy (
gameday_sns_policy
) – created in the previous step. - Lambda Basic Execution Role (
AWSLambdaBasicExecutionRole
) – an AWS-managed policy.
- SNS Publish Policy (
- Click Next: Tags (optional), then Next: Review.
- Enter a name for the role (e.g.,
gameday_role
). - Click Create Role.
- Copy and save the ARN of this role for use in the Lambda function.
- Open the AWS Management Console and navigate to the Lambda service.
- Click Create Function.
- Select Author from Scratch.
- Enter a function name (e.g.,
gameday_notifications
). - Choose Python 3.x as the runtime.
- Assign the IAM role created earlier (
gameday_role
) to the function. - Under the Function Code section:
- Copy the contents of
src/gameday_notifications.py
from your repository. - Paste it into the inline code editor.
- Copy the contents of
- Under the Environment Variables section, add:
NBA_API_KEY
: Your NBA API key.SNS_TOPIC_ARN
: The ARN of the SNS topic created earlier.
- Click Create Function.
- Open the AWS Management Console and navigate to the EventBridge service.
- Go to Rules → Create Rule.
- Select Event Source: Schedule.
- Define the cron schedule for when updates should be sent (e.g., hourly).
- Under Targets, select the Lambda function (
gd_notifications
) and save the rule.
- Open the Lambda function in the AWS Management Console.
- Create a test event to simulate execution.
- Run the function and check CloudWatch Logs for errors.
- Verify that SMS or email notifications are sent to subscribed users.
What I Learned
- Building a real-time notification system with AWS SNS and Lambda.
- Implementing least privilege IAM policies for secure access.
- Automating workflows using EventBridge.
- Integrating external APIs into AWS services.
- Add NBA Parlay Predictions to expand the system.
- Store user preferences (teams, game types) in DynamoDB for personalized alerts.
- Develop a web-based UI for user subscription management.