Most Recent Project:
Overview
This project demonstrates building a containerized API management system for querying sports data. It leverages Amazon ECS (Fargate) for running containers, Amazon API Gateway for exposing REST endpoints, and an external Sports API for real-time sports data. The project showcases advanced cloud computing practices, including API management, container orchestration, and secure AWS integrations.
My Repo:
Exposes a REST API for querying real-time sports data
Runs a containerized backend using Amazon ECS with Fargate
Scalable and serverless architecture
API management and routing using Amazon API Gateway
Sports API Key: Sign up for a free account and obtain your API Key
AWS Account: Create an AWS account & have basic understanding of ECS, API Gateway, Docker & Python
AWS CLI Installed and Configured: Install & configure AWS CLI to interact with AWS
Serpapi Library: Install Serpapi library in your local environment using:
pip install google-search-results
Docker CLI and Desktop Installed: Required to build & push container images
Cloud Provider: AWS
Core Services: Amazon ECS (Fargate), API Gateway, CloudWatch
Programming Language: Python 3.x
Containerization: Docker
IAM Security: Custom least-privilege policies for ECS task execution and API Gateway
sports-api-management/
├── app.py # Flask application for querying sports data
├── Dockerfile # Dockerfile to containerize the Flask app
├── requirements.txt # Python dependencies
├── .gitignore
└── README.md # Project documentation
git clone https://github.com/ifeanyiro9/containerized-sports-api.git
cd containerized-sports-api
aws ecr create-repository --repository-name sports-api --region us-east-1
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com
docker build --platform linux/amd64 -t sports-api .
docker tag sports-api:latest <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/sports-api:sports-api-latest
docker push <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/sports-api:sports-api-latest
1. Create an ECS Cluster
Go to the ECS Console → Clusters → Create Cluster
Name your Cluster: sports-api-cluster
Select Fargate as the infrastructure and create the cluster
2. Create a Task Definition
Go to Task Definitions → Create New Task Definition
Name your task: sports-api-task
Select Fargate as the infrastructure
Add the container:
Name: sports-api-container
Image URI: <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/sports-api:sports-api-latest
Container Port: 8080
Protocol: TCP
Define Environment Variables:
Key: SPORTS_API_KEY
Value: <YOUR_SPORTSDATA.IO_API_KEY>
Create the task definition
3. Run the Service with an Application Load Balancer (ALB)
Go to Clusters → Select Cluster → Service → Create
Capacity provider: Fargate
Deployment configuration family: sports-api-task
Service name: sports-api-service
Desired tasks: 2
Networking Configuration:
Type: All TCP
Source: Anywhere
Load Balancing: Select Application Load Balancer (ALB)
ALB Configuration:
Create a new ALB: sports-api-alb
Target Group health check path: /sports
Create the service
4. Test the ALB
After deploying the ECS service, note the DNS name of the ALB (e.g., sports-api-alb-<AWS_ACCOUNT_ID>.us-east-1.elb.amazonaws.com)
Confirm the API is accessible by visiting the ALB DNS name in your browser and adding /sports at the end:
http://sports-api-alb-<AWS_ACCOUNT_ID>.us-east-1.elb.amazonaws.com/sports
Go to API Gateway Console → Create API → REST API
Name the API: Sports API Gateway
Create a resource: /sports
Create a GET method
Choose HTTP Proxy as the integration type
Enter the DNS name of the ALB, including /sports:
http://sports-api-alb-<AWS_ACCOUNT_ID>.us-east-1.elb.amazonaws.com/sports
Deploy the API to a stage (e.g., prod)
Note the endpoint URL
Use curl or a browser to test:
curl https://<api-gateway-id>.execute-api.us-east-1.amazonaws.com/prod/sports
Setting up a scalable, containerized application with ECS
Creating public APIs using API Gateway
Add caching for frequent API requests using Amazon ElastiCache
Integrate DynamoDB to store user-specific queries and preferences
Secure the API Gateway using an API key or IAM-based authentication
Implement CI/CD for automating container deployments
Open the Amazon ECR console at:
https://console.aws.amazon.com/ecr/
Check if the repository sports-api exists in your ECR
If it does not exist, create a new repository named sports-api
Look for the sports-api-latest tag in the sports-api repository
If the tag is missing, ensure the correct image is pushed to the repository with the sports-api-latest tag
If you do not have permissions to perform the above actions, contact your AWS Administrator
Go to the IAM console at:
https://console.aws.amazon.com/iam/
Find the task execution role used by your ECS task
Ensure it has the necessary permissions to pull images from ECR
If needed, attach the following policy to the role:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage"
],
"Resource": "arn:aws:ecr:us-east-1:137068223119:repository/sports-api"
}
]
}
Open the ECS console at:
https://console.aws.amazon.com/ecs/
Navigate to Task Definitions
Locate the task definition used by the failing task
Click Create new revision
Ensure the image URI is set correctly:
<youraccountid>.dkr.ecr.us-east-1.amazonaws.com/sports-api
Click Update to save the new revision
In the ECS console, go to Clusters
Select the cluster sports-api-cluster
Click on the service running the failing task
Click Update
Select the new task definition revision created in Step 6
Click Deploy to apply the update
In the ECS console, go to the sports-api-cluster
Monitor the Tasks tab to check for new tasks being created
Verify that new tasks are able to pull the image and start successfully
If tasks continue to fail, check ECS task logs and CloudWatch for error messages
If issues persist, ensure your AWS credentials are correct and that the ECS service has the appropriate IAM permissions.
Contact button below.