Skip to content

NBA Game-Day Sports Notification System Using Amazon Web Services: AWS Lambda, SNS and EventBridge

Notifications You must be signed in to change notification settings

Amanda-Igwe/Game-Day-Notifications-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Game-Day-Notifications-System

NBA Game-Day Sports Notification System : AWS Lambda, SNS and EventBridge

Project Overview

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.

Features

  • 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.

Things to know

  • Free account with subscription and API Key at sportsdata.io
  • Free Tier AWS account
  • Basic understanding of AWS and Python

Technical Architecture

nba_API


Technologies

  • 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.

Project Structure

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

Setup Instructions

Clone the Repository

git clone https://github.com/Amanda-Igwe/Game-Day-Notifications.git
cd Game-Day-Notifications

Create an SNS Topic

  1. Open the AWS Management Console.
  2. Search for SNS service
  3. Click the SNS service.
  4. Click Create Topic and select Standard as the topic type.
  5. Name the topic (e.g., gamesupdate_topic) and note the ARN.
  6. Click Create Topic.

Add Subscriptions to the SNS Topic

  1. After creating the topic, click on the topic name from the list.
  2. Navigate to the Subscriptions tab and click Create subscription.
  3. 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).
  1. Click Create Subscription.
  2. 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.
  1. For SMS, the subscription will be immediately active after creation.

sns_subscription

Create the SNS Publish Policy

  1. Open the IAM service in the AWS Management Console.
  2. Navigate to Policies → Create Policy.
  3. Click JSON and paste the JSON policy from gamesupdate_sns_policy.json file
  4. Replace REGION and ACCOUNT_ID with your AWS region and account ID.
  5. Click Next: Tags (you can skip adding tags).
  6. Click Next: Review.
  7. Enter a name for the policy (e.g., gamesupdate_sns_policy).
  8. Review and click Create Policy.

Create an IAM Role for Lambda to assume Temporary Permission

  1. Open the IAM service in the AWS Management Console.
  2. Click Roles → Create Role.
  3. Select AWS Service and choose Lambda.
  4. Attach the following policies:
  • SNS Publish Policy (gamesupdate_sns_policy) (created in the previous step).
  • Lambda Basic Execution Role (AWSLambdaBasicExecutionRole) (an AWS managed policy).
  1. Click Next: Tags (you can skip adding tags).
  2. Click Next: Review.
  3. Enter a name for the role (e.g., gamesupdate_role).
  4. Review and click Create Role.
  5. Copy and save the ARN of the role for use in the Lambda function.

Deploy the Lambda Function

  1. Open the AWS Management Console and navigate to the Lambda service.
  2. Click Create Function.
  3. Select Author from Scratch.
  4. Enter a function name (e.g., gamesupdate_notifications).
  5. Choose Python 3.x as the runtime.
  6. Assign the IAM role created earlier (gamesupdate_role) to the function.
  7. 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.
  1. 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.
  1. Click Create Function.

Set Up Automation with Eventbridge

  1. Navigate to the Eventbridge service in the AWS Management Console.
  2. Go to Rules → Create Rule.
  3. Select Event Source: Schedule.
  4. Set the cron schedule for when you want updates (e.g., hourly).
  5. Under Targets, select the Lambda function (gamesupdate_notifications) and save the rule.

Test the System

  1. Open the Lambda function in the AWS Management Console.
  2. Create a test event to simulate execution.
  3. Run the function and check CloudWatch Logs for errors.
  4. Verify that SMS notifications are sent to the subscribed users.

Lambda_invoke_function

NBA Updates sent to my Email

NBA_ Notifications

What I Learned

  1. Designing a notification system with AWS SNS and Lambda.
  2. Securing AWS services with least privilege IAM policies.
  3. Automating workflows using EventBridge.
  4. Integrating external APIs into cloud-based workflows.

RoadBlocks Experienced

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

About

NBA Game-Day Sports Notification System Using Amazon Web Services: AWS Lambda, SNS and EventBridge

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages