📋 In This Post
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.
| Difficulty | Advanced |
| Lab runtime | Not recorded |
| Measured cost | $23.28 — the most expensive week in the series |
| Deployment | Terraform via HCP Terraform with OIDC |
| Full lab guide | GitHub — prerequisites, Terraform, commands, validation, cleanup |
Cloud Services and Concepts
| Service | Purpose here | What it is |
|---|---|---|
| AWS DevOps Agent | Investigates 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 space | The 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 CloudTrail | From 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, S3 | A 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
- A small scheduled Lambda workload runs normally, reading an SSM parameter on every invocation.
- A deliberate break is introduced: the role's
ssm:GetParameteris revoked. The workload starts failing. - The ground truth is written down first, in a shell script, before the agent is asked anything.
- An investigation is started in the agent space, whose reach is entirely declared in Terraform.
- The agent reads CloudTrail, CloudWatch and the resource configuration, and declares what it could not see.
- It produces a root cause and a mitigation plan. A human reads the plan and performs the repair.
- 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
| Requirement | Detail |
|---|---|
| AWS account | DevOps Agent available in region; permission for Lambda, EventBridge, SSM, S3, IAM |
| A CloudTrail trail | From Week 15. Without it there is nothing to grade the agent against |
| Terraform | >= 1.10 |
| Service namespace | aidevops, 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
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.
Validation and Evidence
Two investigations, both marked against ground truth written beforehand.
| Test | Expected | Actual | Status |
|---|---|---|---|
| Run 1: names the cause | The revoked ssm:GetParameter | Named it, with the causal chain from CloudTrail | Pass |
| Run 1: identifies who and when | Principal and timestamp | Both, from CloudTrail | Pass |
| Run 2 (decoy): reconstructs a sequence | Break, repair, re-break | Reconstructed all three | Pass |
| Declares what it could not see | Names its own gaps | Reported being denied lambda:GetFunction | Pass — the important one |
| Mitigation plan is safe to run | Correct repair | Proposed a broader grant than the original | Fail — read, do not run |
| Evaluation is uncontaminated | Agent works from evidence | It quoted my own SSM description back at me | Fail — see below |
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.
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.
| Item | Rate | This build |
|---|---|---|
| Investigations × 2 | flat, ~0.168 hrs each | $10.06 |
| System learning (one-time) | not listed on the pricing page | $13.22 |
| Idle agent space | free | $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.
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.
Comments