Skip to content
hannctl
PDF

case-studies dragon-sky-finops DESIGN.md

Dragon Sky FinOps: 62% lower infrastructure cost Design and implementation

Linked revenue metrics with infrastructure cost and found unused resources automatically every day with Python, cutting infrastructure cost by up to 62%.

TimeRevenueInfrastructure costRevenue and cost monitored togetherUnused resources flaggedUp to -62%
Infrastructure cost fell by up to 62%.
Runs every dayPythonResources on every cloudUnused resources to clean up
The result becomes a cleanup list that stops cost leaks.

What this code does: Walks through each AWS account and region looking for unused resources. A public IP counts as unused when it is attached to no instance and has no association, and its name, allocation ID, and IP are recorded together. For security groups, names matching the exclusion rules are skipped, and the rest are checked for any network interface that uses them. The results pile up in one common shape (UnusedResource), so cleanup candidates can be read from a single list.

    for account, region, client in provider.regional("ec2"):
        base = {"cloud": "AWS", "project": account.name, "project_id": account.account_id, "region": region}
        for address in client.describe_addresses()["Addresses"]:
            if not address.get("InstanceId") and not address.get("AssociationId"):
                label = (
                    f"{_name(address)} ({address.get('AllocationId')} / {address.get('PublicIp')})".strip()
                )
                records.append(UnusedResource(resource_type="IP", resource=label, **base))
        for group in client.describe_security_groups()["SecurityGroups"]:
            if _excluded(group["GroupName"], rules):
                continue
            used = client.describe_network_interfaces(
                Filters=[{"Name": "group-id", "Values": [group["GroupId"]]}]
            )["NetworkInterfaces"]
            if not used:
© 2026 Kim JunHyun · Built with Astro · The infrastructure behind this site is code too

↑↓ move · Enter open · Esc close

Choose a theme

Click a badge to switch to that theme on the same content. Dragging only swings it.

Back to the front page →