
The Bug Wasn’t in the Code: How AWS DevOps Agent Solved a Mystery I Couldn’t
Investigating a post-deploy Lambda failure where the handler was correct but the execution role lacked dynamodb:GetItem. AWS DevOps Agent correlated the alarm, function, and DynamoDB table to pinpoint the root cause and recommend a least-privilege fix.
Ever stared at a piece of code that looks perfect, but fails every single time
you run it? I recently did. Here’s how an AI teammate found the problem in minutes — and what it taught me about how modern apps really break.
Meet AWS DevOps Agent
Before the story, a quick introduction to the star of it.
AWS DevOps Agent is an AI teammate for running your AWS environment. Picture an on-call engineer who never sleeps: it continuously watches your AWS resources — Lambda functions, databases, alarms, logs, IAM roles — and learns how they all connect.
When something breaks, you don’t dig through dashboards and log groups yourself.
You just ask it in plain English, the way you’d ask a teammate:
“My app started failing after a deploy — what’s wrong and how do I fix it?”
The agent investigates across your resources, figures out the root cause,
and hands you a fix in clear steps. What makes it genuinely useful:
- 🗣️ No code required — describe the problem in normal language.
- 🔍 It sees the whole picture — it correlates the alarm, the failing
service, and everything that service depends on.
- 🧠 It explains its reasoning — so you learn why it broke, not just what
to click.
Setup is light: you create an Agent Space (its workspace, connected to your
AWS account with read-only access) and chat with it in the DevOps Agent web app.
Now, the mystery it helped me solve.
The Setup: A Simple App That Suddenly Broke
I had a tiny app — an AWS Lambda function, challenge4-app-fn, that reads one product from a DynamoDB table and returns it. Nothing fancy. It had been working fine.
Then, right after a deploy, every single request started failing.
So I did the obvious thing: I opened the code. And this is where it got
frustrating — the code looked completely correct.
def handler(event, context):
resp = ddb.getitem(TableName=TABLE, Key={"id": {"S": "1"}})
return {
"statusCode": 200,
"body": json.dumps({"item": resp.get("Item", {})}),
}Read an item, return it. That’s it. There was no bug to find here. So why was it failing on every run?
The First Clue , When I actually ran the function, it didn’t throw a code error. It threw a permissions error:

That was the giveaway. The code was fine. The permission to run that code
against DynamoDB was missing. Something in the deploy had changed around the function, not inside it.
Enter the DevOps Agent
Rather than hunting through IAM roles and policies by hand, I opened the DevOps Agent web app and simply asked:
“My app challenge4-app-fn started failing on every request after a deploy, but the code looks correct. Investigate the root cause and tell me how to fix it.”

The agent went to work. It pulled together the error alarm, the Lambda function, and the DynamoDB table the function depends on — and connected the dots for me.
Its conclusion:
- The function’s IAM execution role only had the basic logging policy
(AWSLambdaBasicExecutionRole).
- The “bad deploy” never granted that role permission to read the DynamoDB table.
- So the code was correct — but the identity running it couldn’t reach its own database.
In one line: the bug wasn’t in the code. It was in what the code was allowed
to do.

The Fix — and It Wasn’t a Code Change
The agent recommended granting the role least-privilege read access to that one table. So I added a small policy to the function’s execution role:
{ "Version": "2012–10–17", "Statement": [ { "Effect": "Allow", "Action": ["dynamodb:GetItem"], "Resource": "arn:aws:dynamodb:us-east-1:<account>:table/challenge4-data" } ]}Not a single line of code touched. Just the permission the code always needed.
I ran the function again:

A clean 200, the seeded product returned, and the error alarm went green. App healthy again. 🎉
What This Taught Me
Three takeaways I’m keeping:
1. Correct code isn’t enough. A function also needs permission to talk to
the resources it depends on. When good code fails on every run, look at the environment around it — IAM roles, permissions, configuration.
2. You don’t have to be an expert to investigate. I described the problem in
plain English, and the DevOps Agent pointed me straight at the root cause. It turned a “where do I even start?” moment into a five-minute fix.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article