AWS Builder Center
Weekend Showcase Challenge: Archival Agent

Weekend Showcase Challenge: Archival Agent

Every AWS account produces thousands of CloudTrail events a day and almost nobody reads them. Archival Agent reads them instead. Once a day it pulls the previous day's activity, strips out anything secret, drops the noise, and groups what's left into episodes so a failed deployment reads as one story rather than thirty rows.

Software Engineer @ Factset

Vision and what it does

The problem

Every AWS account is busy every day. Deployments go out, IAM policies change, security groups get edited, and calls fail.
All of it lands in CloudTrail, and almost nobody reads it. That isn't laziness. CloudTrail is built for searching, not for reviewing. It will find an event once you know what you're looking for, but it won't tell you what you ought to be looking at.
My own account logged 5,032 management events on an ordinary day. 368 of them were failures. Nothing was on fire, so nobody looked, and I only know the number because I built something that counts it.
That's the gap. There's no shortage of data. What's missing is anyone reading it.

How the agent works

Once a day it runs on its own and reports on the day before: what changed, what failed, and what needs a look.
Most of the work happens before the AI gets involved, and that's on purpose. It pulls CloudTrail management events for the previous day, strips out anything secret, and throws away the noise — read-only calls, polling, repeated identical changes, and its own activity. What's left gets grouped into episodes, so a stack deployment shows up as one item instead of twenty rows.
Then a Strands agent on Amazon Nova Pro looks at the episodes that matter and writes a summary. A validator checks that summary before it goes anywhere. The full report goes to a private S3 bucket and a short version comes by email.
The agent only reads. It can't change anything in the account.


What the model does

Collecting, redacting, filtering and grouping are all plain code. Every number in the report comes from that code, not from the model, so the totals are always right.
Nova only sees a clean list of episodes, capped at the most significant 25. Every time I gave it a smaller job, the output got better. It went from "analyse this account" to "explain these episodes and point at the events you used."
After it writes, a validator checks that each claim points at a real event ID. It throws out anything destructive, anything that widens permissions, and any cost claim the events don't support. If the output fails those checks, the run writes a plain report from the episode summaries instead. It never says the AI succeeded when it didn't.
Checking event IDs turned out not to be enough. The model isn't asked to count anything, but it will still write a count into a sentence now and then, and I found a report whose summary said "195 failed events" while the totals directly above it correctly said 368. So the validator now pulls the numbers out of the model's prose too, and drops any sentence stating a figure the events don't support. A missing sentence beats a wrong number sitting next to a right one.

The console

A daily email tells you about one day. That's fine for spotting problems and no help at all for judging whether things are getting better.
It can't tell me failures have been climbing all week, or that the model fell back to the plain report three days running. Those answers were already in S3, in every report written since July. Nothing ever read them back.
The console does. It goes through every stored report and charts activity, failures, episodes by category, and how the agent itself has been doing.






How I built it

Turning raw events into something readable

This is the part that makes the whole thing work, and it's all plain code.
CloudTrail gives you one row per API call. A single  CreateStack  that fails and rolls back can be thirty rows spread over four minutes, from three different principals, and reading them in order tells you almost nothing.
So before anything else happens, related events get correlated into one episode: same stack, same resource, or same session, inside a time window. Each episode carries the actor, the mechanism, the regions and resources it touched, whether it ended in failure, and a one-line summary written by code.
The run for 27 August is a fair example. CloudTrail returned 5,032 management events. Filtering dropped 3,853 read-only calls, 558 known-noisy ones, 70 duplicates and 2 of the agent's own, leaving 549. Those 549 became 50 episodes.
So roughly 89% of what CloudTrail recorded never reached the model at all. That ratio is the whole point. It's what makes the report readable, and it's what keeps the model's job small enough to do well.

Not running twice

The scheduler retries on failure, and a full run takes minutes, so a slow-but-succeeding run could easily get started twice.
Each date gets a lock file written with an S3 conditional write, so only one run can claim a day. When a run finishes it writes a marker recording which run won, and a second attempt sees the marker and stops. Retries are safe, and reruns need an explicit  force  flag.

Reading the history out of S3

For the console, my first thought was a DynamoDB table with an index. It turned out I didn't need one.
The agent already writes a  report.json  for each run, filed under the date, plus that same marker file saying which run won. Read the markers, then read the reports they point at, and you have the whole history in a few small  GetObject  calls. Nothing new to keep in sync, and no index that can fall out of step with the reports.
The one catch: if a run died before writing its marker, that date needs a fallback. It's about four lines, in one place.

AWS services used and architecture overview

It runs one way through. EventBridge Scheduler fires once a day and calls a small dispatcher Lambda, which calls  InvokeAgentRuntime . The runtime does the work and hands back a short status. CloudTrail goes in, S3 and SES come out.
Inside the runtime it's a straight pipeline: collect, redact, filter, group into episodes, analyse, validate, render. All of it happens in one container run.

Service
What it does here
Bedrock AgentCore Runtime
Runs the agent as an ARM64 container
Bedrock (Nova Pro)
The model
Strands Agents SDK
Agent framework and read-only tools
EventBridge Scheduler
Daily trigger
Lambda + Function URLs
Dispatcher and the two consoles
CloudTrail
Where the activity comes from ( LookupEvents )
S3
Private, encrypted report storage
SES
The daily email
CloudWatch + AgentCore Observability
Traces, model and tool calls
SAM + IAM
Infrastructure and tight roles

What the summer taught me

I’ve created and deployed a couple of agents, each with a different theme. Experimenting with different types of agents helped me get a better understanding of the Strands Agents SDK and Bedrock AgentCore.

Link to the app and repo

It shows 42 real days: 10,883 events analysed, 5,465 failures, 3,413 episodes, and the model succeeding 95.2% of the time with two fallback days. Account details and resource names are left out.

A builder who inspired me

@vivekraja who has been a great inspiration through his open-source contributions to AWS repositories, including Strands Agents and OpenClaw OSS and also his work in the community leading UG Madurai.
Really inspiring to see someone who keeps building, contributing, and bringing the community along with him.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article