Home› Blog› Week 16 - AWS DevOps Agent: The Agent Was Right, a…
AWS Weekly Lab AWS Terraform

The agent was right, and I still had to check

An investigating agent does not return a metric. It returns anarrative— and a narrative is persuasive whether or not it is correct. So this week is an evaluation rather than a demonstration: break something in a known way, write the answer down before asking, and grade the agent against the CloudTrail record built in Week 15. It passed twice, including against a deliberate decoy. Then I found I had left the answer key lying in the room.

Verified against current vendor documentation on 26 August 2026. Pricing, limits and API behaviour were checked against the official docs on that date. Cloud services change fast — if you are reading this much later, treat the specifics as a starting point and re-check the linked sources.
AWS Platform Engineering Lab · Week 16 of 52

Lab Overview

Every incident ends with somebody writing a sentence. "The IAM change at 14:02 removed the parameter read, and that is why orders stopped." That sentence is the deliverable — it goes in the postmortem, the next person reads it, and the fix is built on it.

The problem. An investigating agent writes that sentence for you, in about sixteen minutes, at three in the morning. That is genuinely useful, and it is the exact reason to be careful: a fluent wrong sentence and a fluent right one look identical. A metric that is wrong is visibly wrong. A narrative that is wrong reads like an explanation.

The objective. Not "can an agent investigate" — obviously yes. The question is how would I know if it were wrong, answered before an agent's conclusion is allowed to shorten anybody's thinking.

The outcome. The agent was right, twice. I still had to check — and the checking found that I had left the answer key in the room.

DifficultyAdvanced
Lab runtimeNot recorded
Measured cost$23.28 — the most expensive week in the series
DeploymentTerraform via HCP Terraform with OIDC
Full lab guideGitHub — prerequisites, Terraform, commands, validation, cleanup

Cloud Services and Concepts

ServicePurpose hereWhat it is
AWS DevOps AgentInvestigates an incident and produces a root cause and a mitigation plan. Billed per agent-second of active work.An AWS-run agent that investigates an operational problem and reports what it believes the cause to be. It recommends; it does not change anything.
Agent spaceThe agent's declared reach — what it may read, defined entirely in Terraform.The boundary an agent works inside. Everything the associated account can reach is in scope, which makes the association the blast radius.
AWS CloudTrailFrom Week 15. The record of what actually happened, against which the agent's story is graded.Records who called which AWS API, when, and from where. It answers who did it, not what the data contained.
AWS Lambda, EventBridge, SSM, S3A small scheduled workload that can be broken cleanly and repaired.The workload being watched: EventBridge triggers, Lambda runs, Systems Manager holds the configuration, and S3 holds the output.

"Monitor" is not a setting here, it is the only option. AccountType has exactly one legal value, and no actions-role property exists on either CloudFormation resource. The agent reads and recommends; it cannot act, and that is enforced by the service rather than chosen by me.

Grading, not admiring. The method is to write the ground truth down before asking, then mark the answer against it. Anything recorded afterwards is a reaction to the answer, not a test of it.

Architecture and Workflow

aws AWS Cloud The observed workload EventBridge rate(5 minutes) order processor reads its config 1 SSM Parameter processing-mode 2 S3 order records CloudWatch Errors, 300 s The break: a human deletes the config-read policy. The code never changed. The agent — the association is the blast radius Operator App where a human asks the question AgentSpace · week16-agent no budget or duration cap Association · one AWS account everything the agent can reach It found the cause. I still had to check it. Deployed through awscc, not the AWS provider: the hashicorp/aws provider ships no DevOps Agent resources.
The workload, the break a human caused, and the agent whose reach is one association wide.
  1. A small scheduled Lambda workload runs normally, reading an SSM parameter on every invocation.
  2. A deliberate break is introduced: the role's ssm:GetParameter is revoked. The workload starts failing.
  3. The ground truth is written down first, in a shell script, before the agent is asked anything.
  4. An investigation is started in the agent space, whose reach is entirely declared in Terraform.
  5. The agent reads CloudTrail, CloudWatch and the resource configuration, and declares what it could not see.
  6. It produces a root cause and a mitigation plan. A human reads the plan and performs the repair.
  7. The answer is marked against the ground truth written in step 3.

Design decisions

A second, decoy investigation. One correct answer proves very little. The decoy run introduced a repair and a re-break, so the agent had to reconstruct a sequence rather than name a single event.

No auto-remediation. An agent that can act on a wrong narrative is a different risk category from one that can only propose it. I originally wrote this up as a design decision; reading the CloudFormation schemas showed it is not one — the service permits nothing else.

Both service roles double-scoped. aws:SourceAccount pins the caller to this account, aws:SourceArn to an agent space ARN in this account and region, against the confused-deputy case.

Prerequisites

RequirementDetail
AWS accountDevOps Agent available in region; permission for Lambda, EventBridge, SSM, S3, IAM
A CloudTrail trailFrom Week 15. Without it there is nothing to grade the agent against
Terraform>= 1.10
Service namespaceaidevops, not devops-agent — getting it wrong yields a trust policy that looks right and never matches

Budget warning, and it is the real one. This is the most expensive week in the series at $23.28. An investigation costs a flat $5.03 regardless of effort, and there is a one-time $13.22 "system learning" charge that does not appear on the pricing page at all. Budget for it before you start.

Implementation

A breakable workload, an agent space with both associations, and the grading script. The lab guide carries the full Terraform and the break/repair scripts.

week-16-devops-agent-investigations/
|
+-- terraform/
|   +-- environments/dev/   HCP backend, OIDC, wires the modules
|   +-- modules/workload/   the Lambda, its schedule, SSM parameter and bucket
|   +-- modules/agent/      agent space, both service roles, associations
|
+-- scripts/                break, repair, and the ground-truth grader
Only the directories that matter. The full repository is on GitHub.

The grading script is the whole method, and it is one file. It records what was broken, when, and by which principal — before the agent is asked. That single discipline is the difference between an evaluation and an anecdote.

AWS DevOps Agent console listing one agent space named week16-agent
One agent space, created by Terraform. Account ID redacted.

Validation and Evidence

Two investigations, both marked against ground truth written beforehand.

TestExpectedActualStatus
Run 1: names the causeThe revoked ssm:GetParameterNamed it, with the causal chain from CloudTrailPass
Run 1: identifies who and whenPrincipal and timestampBoth, from CloudTrailPass
Run 2 (decoy): reconstructs a sequenceBreak, repair, re-breakReconstructed all threePass
Declares what it could not seeNames its own gapsReported being denied lambda:GetFunctionPass — the important one
Mitigation plan is safe to runCorrect repairProposed a broader grant than the originalFail — read, do not run
Evaluation is uncontaminatedAgent works from evidenceIt quoted my own SSM description back at meFail — see below
Root cause tab naming the deleted config-read inline policy, with an investigation gaps section reporting access denied on lambda GetFunction
The cause, with the principal and the timestamp: DeleteRolePolicy at 15:57:32Z. Matches the ledger. Note the Investigation gaps panel underneath — it reports being denied lambda:GetFunction rather than quietly guessing around the hole.
Decoy investigation root cause reconstructing the full sequence of deletion, brief restoration, and second deletion
It reconstructed the entire sequence rather than the most recent change: deleted at 15:57:32Z, briefly re-added at 17:24:41Z with one successful invocation observed, deleted again at 17:28:59Z. That middle event was my own repair and the single manual invoke I used to verify it — neither was in the prompt, and neither is visible in the alarm.

Security and Cost

Security

The agent reads and recommends; it never acts — enforced by the service, not chosen by me. AccountType accepts only monitor and no actions-role property exists, so the whole IaC path is read-only.

Both service roles double-scoped with aws:SourceAccount and aws:SourceArn, against the confused-deputy case.

The service namespace is aidevops, not devops-agent. Getting it wrong yields a trust policy that looks right and never matches.

AWS managed policies rather than hand-rolled read access. Hand-writing least-privilege across every service an investigator might touch is a losing game.

The standing grant is the thing to remove. An idle agent space costs nothing — verified on every meter — so what persists is not a bill but a role a managed AWS service can assume to read your account.

Cost

$23.28 measured. After teardown, $0.00.

ItemRateThis build
Investigations × 2flat, ~0.168 hrs each$10.06
System learning (one-time)not listed on the pricing page$13.22
Idle agent spacefree$0.00, verified on every meter
Lambda, EventBridge, SSM, S3—effectively free at lab volume

An investigation costs a flat rate regardless of effort. Sampling the meter every ninety seconds through both runs produced the same figure each time — 0.168 hours, $5.03. The decoy run did visibly more work: more steps, more tool calls, a longer wall-clock. It cost the same. Whatever "agent-second" measures, it is not proportional to the investigating you can see.

Decoy investigation summary with an error rate chart annotated with both the Terraform timeout change and the IAM policy deletion
Look at the Error rate over time chart: the Terraform timeout change is plotted on it, annotated by name, right beside the policy deletion markers. It saw the deploy, placed it on the timeline, and declined to rank it as the cause. That is a stronger result than simply missing it.

Troubleshooting and Lessons

I left the answer key in the room

Problem. The first investigation's root cause ended with a sentence I did not expect: "The SSM parameter's own description confirms this was a deliberate break."
Root cause. It did — because I wrote it, in the Terraform, months earlier:

description = "Read on every invocation. Revoking the role's ssm:GetParameter is the deliberate break."

That description is a comment to a human reader and a signpost to anything that can read the AWS API. The agent read it and named the exact mechanism the test was about.
Resolution. Scrub the environment before evaluating. Less was invalidated than it first appears — the description says which permission matters, not who removed it, when or from where, and the causal chain still came from CloudTrail. The decoy run reconstructed a sequence the description could not have contained.
Lesson. Your resource descriptions are inputs to the agent. Scrub them before evaluating; write them well before operating.

The declared gaps matter more than the conclusion

Problem. How do you trust a fluent narrative at all?
Root cause. You cannot, from the narrative. You can from what it admits it could not see.
Resolution. The agent reported being denied lambda:GetFunction and said so.
Lesson. Being told it was denied something is what makes the rest believable. An agent that returns the same confident paragraph whether or not it could see the evidence is the one to worry about.

Read the mitigation plan; do not run it

Problem. One run proposed a repair broader than the permission that had been removed.
Root cause. A plan optimises for "make it work", not for "restore the prior boundary".
Resolution. A human performed the repair, scoped to what was actually revoked.
Lesson. The plan is a proposal from something that cannot act. Keep it that way.

Cleanup and Key Takeaways

Everything this week creates is a Terraform resource, including the agent space and both associations, so nothing is left behind by design. Two things still need confirming:

  • The agent space. Left behind it costs nothing while idle — genuinely nothing, verified on every meter — which is exactly what makes it easy to forget. What persists is not a bill but a standing grant: a role a managed AWS service can assume to read your account. Remove it deliberately.
  • The ServiceNow OAuth endpoint is not managed by Terraform and does not disappear with the stack. Deactivate the Application Registry record, or the credential outlives the lab.

The observed workload tears down with everything else — the S3 bucket carries force_destroy and a seven-day lifecycle rule, so teardown never needs a manual empty.

Key takeaways

  • An agent returns a narrative, and narratives persuade regardless of accuracy. A wrong metric looks wrong; a wrong explanation reads like an explanation. That asymmetry is the whole reason to grade rather than admire.
  • Write the ground truth down before you ask. Anything recorded afterwards is a reaction to the answer, not a test of it.
  • Your resource descriptions are inputs to the agent. I put the answer in an SSM parameter description and it was quoted back to me.
  • The declared gaps matter more than the conclusion. An agent that sounds equally confident with and without the evidence is the one to distrust.
  • Price the thing before you run it. A flat $5.03 per investigation and an undocumented $13.22 one-time charge made this the most expensive week in the series.

References

Comments

How was your experience?
Your feedback helps improve this site.
PoorExcellent