PyForge is sold only here, on the official py-forge.com website — beware of imitations.

All articles
pythonautomationmicrosaascloud

Automating Cloud Infrastructure Waste Detection with CloudPrune CLI

PyForge Team 6 min read2026-10-16

Cloud waste rarely happens in a single massive incident. It accumulates silently: a developer creates a test RDS instance, takes a snapshot, deletes the instance, and forgets the snapshot. Multiply that across dozens of accounts, and you are burning thousands of dollars every month on idle infrastructure.

The Cost of Unmonitored Orphan Resources

In multi-account AWS and GCP setups, tracking unattached EBS volumes in the 'available' state, unassociated Elastic IPs, and legacy RDS snapshots manually via web consoles is inefficient and error-prone. CloudPrune CLI wraps cloud provider SDKs into an automated audit suite with zero external daemon dependencies.

Programmatic Resource Auditing in Python

At its core, CloudPrune inspects block devices, network interfaces, and snapshot metadata using lightweight SDK calls. Below is a simplified representation of how CloudPrune queries unattached AWS EBS volumes across specified regions:

python
import boto3
from typing import List, Dict, Any

def scan_unattached_ebs(regions: List[str]) -> List[Dict[str, Any]]:
    unattached_volumes = []
    for region in regions:
        ec2 = boto3.client('ec2', region_name=region)
        response = ec2.describe_volumes(
            Filters=[{'Name': 'status', 'Values': ['available']}]
        )
        for vol in response.get('Volumes', []):
            unattached_volumes.append({
                'region': region,
                'volume_id': vol['VolumeId'],
                'size_gb': vol['Size'],
                'monthly_cost_usd': vol['Size'] * 0.10
            })
    return unattached_volumes

Continuous Auditing via CI/CD Pipeline

Manual CLI tools only work if engineers remember to run them. CloudPrune comes packaged with ready-to-run GitHub Actions that execute scheduled audits, output structured JSON reports, and optionally alert engineers via Slack or Webhooks before monthly billing cycles hit.