DEV Community

Rahman Badru
Rahman Badru

Posted on

Day 2: Creating NBA Game Day Notification System using Event-Driven Architecture

Project Description

This article details building a notification system using event driven architecture that sends NBA Game day Results to your mail at specific intervals.

This is the second project for the Devops All Stars Challenge

Project Architecture

Image description

Project Requirements

The following services/tools are required for this project:

  1. AWS Lambda
  2. AWS EventBridge
  3. AWS SNS (Simple Notification System)
  4. Python

Project Workflow

Basically the project uses AWS EventBridge to run a scheduled rule at intervals that triggers the Lambda Function which contains a python script to pull game data via the Sports Data API and send to an SNS Topic which is then now sent to either your mail or sms

The Project can be found here: Gameday-Notification

This project is implemented as follows:

Create AWS SNS TOPIC

  1. Open the AWS Management Console
  2. GO to SNS
  3. Click on topics, click create topic
  4. Select Standard as topic type
  5. Name your topic (e.g gameday-topic) and click create topic

Create a Subscription for the Topic

  1. Click on your topic
  2. Click create subscription
  3. Set Protocol to email
  4. Put your mail
  5. Click create Subscription
  6. Confirm the subscription from your mail

Create an 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 gd_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., gameday-policy).
  8. Review and click Create Policy.

Create IAM Role for Lambda

  1. Open the IAM service in the AWS Management Console.
  2. Navigate to Roles -> Create Role
  3. Click on use case drop down and click Lambda
  4. Click Next and then attach two policies:
    • The policy create earlier (gameday-policy)
    • The Lambda Basic Execution Role (AWSLambdaBasicExecutionRole) (an AWS managed policy).
  5. CLick Next, skip tags and create the role

IAM ROLE

Create 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., gameday-function).
  5. Choose Python 3.x as the runtime.
  6. Assign the IAM role created earlier (gameday-role) to the function.
  7. Under the Function Code section:
    • Copy the content of the src/gd_notifications.py file from the repository.
    • Paste it into the inline code editor.
  8. 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.
  9. Click Create Function

Set up EventBridge Schedule to trigger Lambda

  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 (gameday-function) and save the rule.

Event Bridge

Test the System

  1. Open Lambda function and click on the function you created
  2. click on test and name the event
  3. Test the function
  4. Verify you get a mail confirming it was successful

Successful Game day Updates

Conclusion

This project demonstrates how to build a notification system using event-driven architecture on AWS. By leveraging AWS Lambda, EventBridge, and SNS, you can create a reliable and efficient system to receive NBA Game Day updates via email or SMS. This setup is a great example of automating tasks and building scalable systems using cloud services.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more