DEV Community

Cover image for I Built an AI Tool That Finds Wasted Cloud Spending — And Its Carbon Footprint. Published: True
Raghu Putta
Raghu Putta

Posted on

I Built an AI Tool That Finds Wasted Cloud Spending — And Its Carbon Footprint. Published: True

The difficulty

If you’re using Google Cloud, you’re probably paying for stuff you don’t need anymore—a server someone forgot to turn off, a storage disk someone forgot to delete,

or an IP address someone forgot to release. "That waste is costing us money." It consumes electricity. It generates carbon emissions. Almost nobody tracks those alongside the cost.

I wanted a tool that could find both problems simultaneously, without me having to think. So I made one.

Live demo: https://greenops-dashboard-845589445410.us-central1.run.app/
Code: https://github.com/raghu-putta/greenops-agent

How it works: 4 AI agents in a row

Imagine an assembly line in which each worker has only one job:

Carbon Scout scans your Google Cloud project and reports on everything that looks like it might be unused or forgotten—idle servers, unattached storage disks, and unused reserved IP addresses.
GreenOps Analyzer takes that list and adds two numbers to each item: how much it’s costing you in dollars, and how much it’s costing the planet in carbon emissions.

Optimization Executor takes each finding and makes it an action: stop this server, delete this disk, release this address. It shows you the plan first; it only changes if you say go.
Report Generator rolls up the entire run into a downloadable report so you (or your boss or your sustainability team) have something nice to look at.

Powered by: FastAPI (the web framework), Google’s Agent Development Kit (a library for building AI agents), Gemini 2.5 Pro (the AI model doing the reasoning), and Google Cloud Run (where it’s all running).

The “bug” that was not a bug:
The dashboard has a terminal-style live window that shows you what each agent is doing in real time, using a technique called Server-Sent Events (basically, the server streams updates to your browser one at a time instead of making you refresh).

And then at some point that window just stopped showing anything. Nothing. My backend logs told me that the updates were still being sent, so the data was leaving the server just fine. I spent time looking at the frontend code, adding debug logs, and looking at the network tab in the browser, thinking I wrote something wrong.

The actual issue: Google Cloud Run has a default timeout on how long it will keep a connection open, and my agent runs were exceeding that timeout. The connection was getting dropped midstream—not for a code bug, but for a platform setting. The workaround was a single line in my deployment command, telling Cloud Run to allow longer-running connections and to keep at least one instance warm so there isn’t a cold-start delay:

bashgcloud run deploy greenops-dashboard \

  • timeout 3600 \ --min-instances 1 \ --allow-unauthenticated

Moral of the story: If you have a real-time feature that just breaks and your server logs tell you everything is fine, check the connection time limits of your hosting platform before you assume it's your code.

How you can use your Google Cloud credentials

This tool needs access to scan your Google Cloud project and requires your credentials. I didn’t really want to build something that’s just “trust us with your login” as the security model. Here’s the real flow:

Credentials are typed into the browser and are only stored in temporary browser memory, never permanently saved on your device
They are sent over a secure (HTTPS) connection for one scan
The server keeps them in memory only—never written to file, never stored in a database
They vanish instantly after the scan is finished. No leftovers and the system will not allow a credential to be used for a second run

I looked at three ways to handle this and chose the simplest one that's still easy to audit for now with a plan to eventually replace it with a proper "Sign in with Google" flow so nobody has to type in raw credentials at all.

What's next?

Giving the AI more background context to refer to before it answers (I'm still weighing up whether the increased accuracy is worth the extra monthly cost)
Add “Sign in with Google” so you never have to worry about handling credentials.

Give it a try yourself

Dashboard: https://greenops-dashboard-845589445410.us-central1.run.app/
Code: https://github.com/raghu-putta/greenops-agent

If you’re building similar tools around cloud cost or sustainability, I’d love to compare notes in the comments.

Top comments (0)