NBA Game-Day Sports Notification System : AWS Lambda, SNS and EventBridge
This project is a sports nofication system that sends real-time NBA game day score notifications to subscribed users via SMS/Email. It utilizes Amazon SNS, AWS Lambda and Python, Amazon EventBridge and NBA APIs to provide sports fans with scheduled up-to-date game information. The project demonstrates my understanding of AWS Services and least priviledge best practices in cloud security using IAM Role.
- Fetches live NBA game scores using an external API.
- Sends formatted score updates to subscribers via SMS/Email using Amazon SNS.
- Scheduled automation for regular updates using Amazon EventBridge.
- Designed with security in mind, following the principle of least privilege for IAM roles.
- Free account with subscription and API Key at sportsdata.io
- Free Tier AWS account
- Basic understanding of AWS and Python
- 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.
Game-Day-Notifications/
├── src/
│ ├── gamesupdate_notifications.py # Main Lambda function code
├── policies/
│ ├── gamesupdate_sns_policy.json # SNS publishing permissions
│ ├── gamesupdate_eventbridge_policy.json # EventBridge to Lambda permissions
│ └── gamesupdate_lambda_policy.json # Lambda execution role permissions
├── .gitignore
└── README.md # Project documentation
git clone https://github.com/Amanda-Igwe/Game-Day-Notifications.git
cd Game-Day-Notifications
- Open the AWS Management Console.
- Search for SNS service
- Click the SNS service.
- Click Create Topic and select Standard as the topic type.
- Name the topic (e.g., gamesupdate_topic) and note the ARN.
- Click Create Topic.
- After creating the topic, click on the topic name from the list.
- Navigate to the Subscriptions tab and click Create subscription.
- Select a Protocol:
- For Email:
- Choose Email.
- Enter a valid email address.
- For SMS (phone number):
- Choose SMS.
- Enter a valid phone number in international format (e.g., +1234567890).
- Click Create Subscription.
- If you added an Email subscription
- Check the inbox of the provided email address.
- Confirm the subscription by clicking the confirmation link in the email.
- For SMS, the subscription will be immediately active after creation.
- Open the IAM service in the AWS Management Console.
- Navigate to Policies → Create Policy.
- Click JSON and paste the JSON policy from gamesupdate_sns_policy.json file
- Replace REGION and ACCOUNT_ID with your AWS region and account ID.
- Click Next: Tags (you can skip adding tags).
- Click Next: Review.
- Enter a name for the policy (e.g., gamesupdate_sns_policy).
- Review and click Create Policy.
- Open the IAM service in the AWS Management Console.
- Click Roles → Create Role.
- Select AWS Service and choose Lambda.
- Attach the following policies:
- SNS Publish Policy (gamesupdate_sns_policy) (created in the previous step).
- Lambda Basic Execution Role (AWSLambdaBasicExecutionRole) (an AWS managed policy).
- Click Next: Tags (you can skip adding tags).
- Click Next: Review.
- Enter a name for the role (e.g., gamesupdate_role).
- Review and click Create Role.
- Copy and save the ARN of the 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., gamesupdate_notifications).
- Choose Python 3.x as the runtime.
- Assign the IAM role created earlier (gamesupdate_role) to the function.
- Under the Function Code section:
- Copy the content of the src/gamesupdate_notifications.py file from the repository.
- Paste it into the inline code editor.
- Under the Environment Variables section, add the following:
- NBA_API_KEY: your NBA API key.
- SNS_TOPIC_ARN: the ARN of the SNS topic created earlier.
- Click Create Function.
- Navigate to the Eventbridge service in the AWS Management Console.
- Go to Rules → Create Rule.
- Select Event Source: Schedule.
- Set the cron schedule for when you want updates (e.g., hourly).
- Under Targets, select the Lambda function (gamesupdate_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 notifications are sent to the subscribed users.
NBA Updates sent to my Email
- Designing a notification system with AWS SNS and Lambda.
- Securing AWS services with least privilege IAM policies.
- Automating workflows using EventBridge.
- Integrating external APIs into cloud-based workflows.
If you encounter an error here, and maybe your status code says hello lambda. Go to your code and re-copy and paste again. Click deploy and click test. The deployment puts that code into action before you test. I experienced it and was able to troubleshoot it.
Here is my Medium for a detailed step-by-step guide for this project