A FastAPI-based REST API that exposes DevOps utility endpoints for system metrics monitoring and AWS resource information.
DevOps-Utilities/
├── app/
│ └── api.py # FastAPI app definition & route registration
├── images/
│ └── image # Image Handling
├── resources/
│ └── bucket.py # Amazon S3 operation create,list,delete OPTIONAL
├── routers/
│ ├── metrics.py # System metrics router
│ └── aws.py # AWS resources router
├── services/
│ ├── metrics_service.py # psutil-based system metrics logic
│ └── aws_service.py # boto3-based AWS S3 & EC2 logic
├── main.py # Application entry point (uvicorn)
└── requirements.txt # Python dependencies
- Python 3.8+
- AWS CLI configured with appropriate access (see AWS Setup below)
git clone https://github.com/your-username/DevOps-Utilities.git
cd DevOps-Utilitiespython3 -m venv venvsource venv/bin/activateOn Windows, use:
venv\Scripts\activate
pip install -r requirements.txtpython3 main.pyThe server will start at http://0.0.0.0:8080 with hot-reload enabled.
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Greet endpoint (health check) |
| GET | /health |
Returns API health status |
| GET | /metrics |
Returns CPU, Disk & Memory usage |
| GET | /aws/s3 |
Lists S3 buckets (new vs old) |
| GET | /aws/ec2 |
Lists EC2 instances and their states |
Once the server is running, visit:
- Swagger UI: http://localhost:8080/docs
- ReDoc: http://localhost:8080/redoc
Before using the /aws/s3 or /aws/ec2 endpoints, make sure:
- AWS CLI is installed and configured:
aws configureYou'll be prompted to enter:
- AWS Access Key ID
- AWS Secret Access Key
- Default region (e.g.,
us-east-2) - Output format (e.g.,
json)
- Your IAM user/role has the following permissions:
s3:ListAllMyBuckets— for the S3 endpointec2:DescribeInstances— for the EC2 endpoint
The EC2 service queries the
us-east-2region by default. Updateservices/aws_service.pyif you need a different region.
| Package | Purpose |
|---|---|
fastapi |
Web framework for building APIs |
uvicorn |
ASGI server to run the app |
psutil |
System metrics (CPU, disk, RAM) |
boto3 |
AWS SDK for Python |
- The
/metricsendpoint marks the service as "Service not Healthy" if CPU usage exceeds 10%. Adjust thethresholdvalue inservices/metrics_service.pyas needed. - The
/aws/s3endpoint classifies buckets as new (created within the last 90 days) or old (older than 90 days).


