Why I Spent My Weekend Teaching AWS Serverless to Fix Water Leaks at 3 AM: The Story of AegisAI
Why dashboards that just send alerts aren't enough, my weekend battle with AWS setup loops, and how I built an autonomous agent with SAM, Lambda, and DynamoDB.
Why I Spent My Weekend Teaching AWS Serverless to Fix Water Leaks at 3 AM: The Story of AegisAI
Most hackathon projects I see focus on flashy ideas like generating images or making another chatbot. When I joined the WeMakeDevs x AWS Environmental Hacks, I wanted to build something grounded in a boring, everyday real-world problem: water management on a residential campus.
That idea turned into AegisAI—an autonomous agent that monitors campus water tanks and actually steps in to fix issues instead of just pinging someone's phone.
Why another monitoring dashboard wasn't the answer
When I started brainstorming, I realized almost every smart water product out there stops at sending notifications.
A meter detects an abnormal outflow at 3 AM, and the system sends an email: "High outflow detected in Hostel Block B."
The problem is, whoever gets that email is asleep. The email sits unread in an inbox for hours while water keeps draining away. By 7 AM when someone finally wakes up and notices, hundreds or thousands of litres have already gone down the drain.
I wanted to change that pattern. An alert shouldn't be the end of the line—it should be the starting trigger for an automated investigation. If a system can see the anomaly, it should look at the numbers, figure out whether it's a pipe burst or just scheduled maintenance, take a safe action like shutting an isolation valve, and re-check the sensors to confirm the fix worked.
That became the core loop of the project: Detect → Investigate → Decide → Act → Verify.
The weekend build: what went right and what broke
Building this end-to-end on AWS in a couple of days came with some very real hurdles.
The account setup loop
The most frustrating part of the hackathon wasn't the code—it was literally getting past the AWS registration page. Right after adding my card details, the console kept redirecting me back to a "Complete your account setup" page. For nearly three hours, IAM was completely locked, which meant I couldn't create access keys or deploy a single template. A clear status indicator like "payment verification in progress" would have saved a lot of frantic tab refreshing.
Discovering AWS SAM
Once the account cleared, working with AWS SAM (Serverless Application Model) was easily my favorite part of the stack.
Instead of jumping between twenty different screens in the AWS console, I wrote the entire architecture into one
template.yaml file:- Three Lambda functions: one for the API, one minute-by-minute heartbeat trigger, and one for the agent loop.
- Four DynamoDB tables: storing buildings, incident records, audit logs, and sensor telemetry (with TTL enabled so old readings delete themselves).
- An EventBridge rule: to trigger the detector every 60 seconds.
- An SNS topic: for alerting facility staff.
Running
sam deploy and watching the changeset create all the roles, tables, and endpoints automatically saved hours of repetitive clicking.Putting guardrails on the agent
Letting an automated agent control physical utilities (even in a simulation) requires strict guardrails. I wrote the agent code with three hard rules:
- Evidence is mandatory: The agent cannot call any action tools until it has queried all five read-only diagnostic tools (baseline flow, water balance, pump logs, maintenance schedule, and recent readings).
- Reversible actions only: It can only close isolation valve V2 or trip a pump—never anything destructive.
- Always verify: After closing a valve, it waits, reads the meter again, and only marks the incident resolved if the flow has genuinely returned to baseline. If the water keeps flowing, it flags an escalation.
Seeing it run live
Once I hooked the Next.js frontend to the deployed API Gateway, the end-to-end flow finally came together.
In the dashboard, injecting a simulated leak into Hostel Block B immediately spikes the outflow to 48 L/min against its 2.8 L/min baseline. The EventBridge heartbeat picks it up, hands it to the agent Lambda, and within about 15 seconds the agent pulls the evidence, decides on
close_valve , shuts the riser valve on the map, and verifies the outflow drops back to zero.The best part is that it handles other scenarios differently based on evidence. If a tank overflows because of a stuck float switch, it turns off the pump instead. If a scheduled tank flush is happening, it recognizes the maintenance window and leaves it alone.
Takeaways
This project changed how I think about serverless systems. We often talk about Lambda and DynamoDB in terms of scalability and cost, but combining them with autonomous workflows opens up really practical solutions for physical infrastructure.
Instead of building dashboards that demand human attention 24/7, we can build systems that quietly handle routine problems in the background.
- Live Demo: https://aegisai-frontend-two.vercel.app
- Built by: Gauri Sharma for the WeMakeDevs x AWS Environmental Hacks
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article