Twenty Minutes
I checked my AWS bill on a Tuesday and it was $120 higher than the month before. Nothing had changed on my end, no new deploy, no new feature. I spent twenty minutes in Cost Explorer clicking through service breakdowns and came away with a bigger number and zero explanation.
That twenty minutes is the whole reason InfraLens exists.
I didn't want another cost dashboard. I've used the AWS Cost Explorer console enough times to know the problem was never a lack of numbers. It was translation. The console shows you what changed. It doesn't tell you why, and it definitely doesn't tell you in the time it takes to actually act on it.
I had two other AWS ideas on the list, a resource tagging auditor and a multi-account IAM visualizer. I picked this one because it was the only one where the agent had to reason across time, not just describe a snapshot. Cost anomalies aren't a lookup, they're a correlation problem, and that's a fundamentally harder agent design question than "list my EC2 instances."
What InfraLens actually does?
You give it only read access to your AWS account. You ask it questions in plain English. It answers with real numbers, pulled live, not cached, not pre-computed.
- Why did my bill spike last week?
- What am I spending the most on this month?
- Which EC2 instances are sitting idle?
Under the hood, it's a LangGraph ReAct agent with six tools wired to boto3: cost-by-service, cost anomaly detection, and inspection tools for EC2, Lambda, S3, and RDS. The anomaly detector compares the trailing 7 days against the previous 7 and flags anything that moved more than 20%. When it finds something, the agent doesn't stop at "Lambda costs went up." It cross-references invocation metrics from CloudWatch and correlates the spike against whatever changed in that window, usually a cron schedule, a redeploy, or a config change that quietly 8x'd invocation frequency.
The part that actually took the longest.
It wasn't the LangGraph wiring or the tool schemas. It was deciding how credentials move through the system.
First Version
My first version cached the boto3 session at startup, one session, reused across every request. It worked fine for me, testing against my own account. Then I imagined someone else pasting their keys into my tool while I was still running that version, and realized their credentials would sit in memory next to whatever session state came before them. I never actually shipped that version publicly, but the thought experiment was enough to make me rebuild the credential flow from scratch before anyone else touched it.
The obvious approach, cache a boto3 session once and reuse it, is also the wrong one for something that's going to sit in front of strangers' AWS accounts eventually. InfraLens creates a fresh boto3 session per request, and credentials never touch os.environ inside the tool code, only function parameters.
The IAM policy is read-only by design: Cost Explorer plus resource-read access, nothing that can modify or delete. That's not a compliance checkbox, it's the actual reason I was comfortable pointing this at a real account before it had any kind of auth layer in front of it.
What I'd tell someone building something similar
Before this, I thought agent reliability was mostly a prompting problem, get the system prompt tight enough and the tool calls fall in line. Building InfraLens changed that. The prompt never once caused a real incident. The credential handling would have, if I'd shipped my first instinct. The actual reliability problem in agent-to-cloud systems isn't the model's reasoning, it's every boundary where the agent touches something it could accidentally keep.
InfraLens is currently in development, and I'm actively working toward the first public release. I'll share more as it gets closer. If you're interested in how the agent works under the hood, I'll be open-sourcing parts of the implementation along the way.
Loading article