This repository contains the setup_nba_data_lake.py script, which automates the creation of a data lake for NBA analytics using AWS services. The script integrates Amazon S3, AWS Glue, and Amazon Athena, setting up the infrastructure for storing and querying NBA-related data.
The setup_nba_data_lake.py script performs the following actions:
- Creates an Amazon S3 bucket to store raw and processed data.
- Uploads sample NBA data (JSON format) to the S3 bucket.
- Sets up an AWS Glue database and an external table for querying the data.
- Configures Amazon Athena for SQL-based queries.
-
SportsData.io Account:
- Sign up for a free account at SportsData.io.
- Obtain your NBA API key from the "Standings" section.
-
IAM Permissions:
- S3:
s3:CreateBucket,s3:PutObject,s3:DeleteBucket,s3:ListBucket - Glue:
glue:CreateDatabase,glue:CreateTable,glue:DeleteDatabase,glue:DeleteTable - Athena:
athena:StartQueryExecution,athena:GetQueryResults
- S3:
- Go to AWS Console and log in.
- Open CloudShell by clicking the square icon with
>_next to the search bar.
- In CloudShell, type:
nano setup_nba_data_lake.py
- Copy the script from GitHub and paste it into the file.
- Replace api_key under #Sportsdata.io configurations with your SportsData.io API key.
- Save and exit (^X, then Y, then Enter).
In CloudShell, type:
nano .envPaste the following code and replace with your API key:
SPORTS_DATA_API_KEY=your_sportsdata_api_key
NBA_ENDPOINT=https://api.sportsdata.io/v3/nba/scores/json/PlayersSave and exit. Step 4: Run the Script Run the script to set up the data lake:
python3 setup_nba_data_lake.pyOutput:
You should see messages confirming successful resource creation.
Amazon S3: Check for a bucket named sports-analytics-data-lake with sample data in the raw-data folder. Amazon Athena: Use the following query to verify data:
SELECT FirstName, LastName, Position, Team
FROM nba_players
WHERE Position = 'PG';Click Run to see the results.
- Securing AWS services with least privilege IAM policies.
- Automating service creation with Python scripts.
- Integrating external APIs into cloud workflows.
- Automate data ingestion using AWS Lambda.
- Add a data transformation layer with AWS Glue ETL.
- Incorporate advanced analytics and visualizations with AWS QuickSight.

