API grades the utilization of subnets in a VPC (Virtrual Private Cloud).
An improved replica of my internship project at Capital One using LocalStack as a cloud service emulator for AWS services containerized with Docker, Boto3 AWS SDK, Flask web framework, SQLAlchemy ORM with SQLite database, and practicing the MVC architecture pattern.
- API that gathers VPC utilization metrics and returns it for that given account
- Gathers subnet data and calculates % of VPC utilization and assign grade (A-F)
- Provides recommendation for users to address potential VPC health issues based on grade
High Utilization -> Request to expand VPC Low Utilization -> Warning to consolidate VPCs
- Clone this repo
git clone git@github.com:ciaracade/graded-aws-metric-api.git && cd graded-aws-metric-api
- Activate python environment and install dependencies
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Create
.envfile in thesrc/directory with the following variables:
# AWS Configuration
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_DEFAULT_REGION=us-east-1
ENDPOINT_URL=http://localhost:4566
# VPC/Subnet creation limits
VPC_MIN=1
VPC_MAX=3
SUBNET_MIN=2
SUBNET_MAX=5
# Utilization ranges
UTIL_LOW=0.05
UTIL_HIGH=0.95
# Random seed (optional)
RAND_SEED=42
- Make sure Docker is running in the background and start LocalStack server:
localstack start
- Navigate to the
srcdirectory and run the seeding script to populate LocalStack with test VPCs:
cd src
python aws/seed.py
- Start the Flask API:
python app.py
- Use the API locally via Postman or curl:
curl http://127.0.0.1:5000 # or whatever endpoint your flask points to
{
"status": "healthy",
"service": "AWS VPC Health and Utilization Metric API",
"version": "1.0.0",
}
{
"count": 11,
"vpcs": [
{
"cidr_block": "172.31.0.0/16",
"grade": "F",
"last_updated": "2025-09-04T02:07:00.750150",
"name": "unknown",
"state": "available",
"utilization_score": 0.12,
"vpc_id": "vpc-266d0c1019c33c0c8"
},
{
"cidr_block": "10.18.0.0/16",
"grade": "F",
"last_updated": "2025-09-04T02:07:00.750154",
"name": "seed-vpc-1",
"state": "available",
"utilization_score": 38.43,
"vpc_id": "vpc-2b5742ea4f06c8941"
}, ...
{
"vpc": {
"cidr_block": "10.179.0.0/16",
"grade": "F",
"last_updated": "2025-09-04T02:07:00.750161",
"name": "seed-vpc-9",
"state": "available",
"subnets": [
{
"availability_zone": "us-east-1b",
"available_ip_count": 136,
"cidr_block": "10.179.2.0/24",
"grade": "F",
"name": "seed-subnet-9-2",
"state": "available",
"subnet_id": "subnet-7e1a985a8ef38ddb5",
"total_ip_count": 256,
"utilization_score": 46.88
},...
],
"utilization_score": 49.12,
"vpc_id": "vpc-4d5e6ffe3db5fd59c"
}
}
{
"grade": {
"breakdown": {
"cost_optimization": {
"grade": "D",
"score": 58.94,
"weight": "20%"
},
"efficiency": {
"factors": "4 subnets",
"grade": "A+",
"score": 100,
"weight": "30%"
},
"utilization": {
"grade": "F",
"score": 49.12,
"weight": "50%"
}
},
"name": "seed-vpc-9",
"overall_grade": "C",
"overall_score": 66.35,
"recommendations": [
"VPC is well-configured"
],
"vpc_id": "vpc-4d5e6ffe3db5fd59c"
}
}
- Expand efficiency scoring
- Cleaner db seed vs localstack seeding ( to mimic fake aws vpcs )
- Add detailed recommendations for better VPC configurations