AWS Builder Center
Building Cedar Sentinel: An AI Least-Privilege IAM Tightener That Never Applies Anything Without Your Approval

Building Cedar Sentinel: An AI Least-Privilege IAM Tightener That Never Applies Anything Without Your Approval

A solo build for the First Commit hackathon (WeMakeDevs × AWS), Ship It track.

Building real-world applications with AWS, cloud, backend engineering, and AI.
The problem: wildcards that never get tightened
When you're prototyping, it's tempting to write  s3:*  on  Resource: "*"  and move on. That policy ships, the deadline passes, and the blast radius stays. Manual IAM audits are slow and infrequent, so over-permissioned roles pile up.
I wanted a tool that closes that loop automatically, but with a safety property most auto-remediation tools skip: it must never break a working application, and it must never change anything without a human saying yes.
What Cedar Sentinel does Cedar Sentinel reads the IAM policy a Terraform plan requests, compares it to what the role actually did according to CloudTrail, and drafts a tightened least-privilege policy. It then puts that draft through two independent gates before a developer ever sees it, and applies it only after explicit approval. Python CLI (terraform show -json) → EventBridge → SQS → Lambda → CloudTrail → CloudWatch Logs Insights (observed API calls) → Amazon Bedrock (draft tightened Cedar policy) → Coverage check (hard-block on dropped actions) → Amazon Verified Permissions (Cedar schema validation) → DynamoDB (result + per-stage timings) → CLI dry-run diff → explicit approval → IAM PutRolePolicy

Figure 1: Cedar Sentinel pipeline. Bedrock drafts, deterministic gates verify, a human approves, and IAM enforces.
The developer's workflow is two commands:  terraform plan  /  terraform show -json , then  cedar_sentinel.py analyze .
A design decision I got wrong first: Cedar is not the enforcement layer My first architecture had Verified Permissions enforcing the policy. That's a misconception. Amazon Verified Permissions is an authorization engine for your own applications. It does not gate real AWS API calls. AWS IAM is what actually enforces least privilege.
So the corrected design uses Cedar for what it's good at: a formally analyzable, schema-validated representation that catches invalid or contradictory drafts before they're translated into anything real. IAM stays the sole enforcement point. Understanding that boundary turned out to be the most important design lesson of the project.
Safety gate 1: the workload-lockout check The scariest failure mode for any least-privilege generator is silently removing an action that a workload really needs, like something that only runs monthly and looks unused. Bedrock's draft is treated as a suggestion, not a decision, so before Cedar verification runs, a deterministic check compares the draft against every action observed in CloudTrail. If the draft drops any of them, the run is hard-blocked: [WARNING] SAFETY CHECK FAILED: Potential Workload Lockout Detected! The proposed Cedar policy drops observed CloudTrail actions: - s3:GetObject (Observed 142 times in last 7 days)
Action Taken: Deployment blocked. [1] Fall back to original policy [2] Force-apply draft Cedar policy (Override) [3] Re-evaluate with tighter prompt context The tool exits non-zero and asks the developer to choose. There is no silent fallback that would hide the problem.
Safety gate 2: Cedar validation through Amazon Verified Permissions The draft is registered against a Cedar schema in  STRICT  mode. One gotcha here:  CreatePolicy  isn't a dry run, because it stores the policy if validation succeeds. So the verification stage uses a disposable policy store and deletes the policy immediately afterward, while a separate persistent store holds the audit record of approved policies only.
A failed validation gets its own status,  CEDAR_INVALID , distinct from  BLOCKED  and  COMPLETE , so a developer can tell the three outcomes apart at a glance.
Things that fought back 1. CloudTrail Lake was closed to me on kickoff day. AWS closed CloudTrail Lake to customers who hadn't used it before. My account was established, but I had never created a Lake event data store, so creation failed with  InvalidParameterException . My whole baseline design depended on it. I pivoted to a standard CloudTrail Trail delivering management events to CloudWatch Logs, queried with Logs Insights. Nothing downstream needed to change, since Bedrock only ever needed a compact map of observed actions and call counts. Caching that abstraction early saved the pivot.
2. Claude on Bedrock needed a Marketplace subscription my account couldn't complete. Anthropic model invocation failed with  INVALID_PAYMENT_INSTRUMENT  on my debit-card-only account. I switched to Amazon Nova Lite, a first-party model with no Marketplace step, invoked through a cross-region inference profile. It's fast, cheap, and returned structured JSON reliably.
3. A model can be "wrong in a valid-looking way." With zero observed actions, one model drafted  "deny all;" , which isn't valid Cedar. In another run it appended a spurious  forbid  clause to a  permit  policy. I fixed both twice: with clearer prompt rules and few-shot examples, and with a deterministic code-level guard that sanitizes the draft into a canonical  permit(...)  statement. Prompts reduce errors. Guards remove classes of them.
4. A failed validation was being written as  COMPLETE . A real CloudWatch log showed Cedar validation failing right before the result was stored as successful. That's the worst kind of bug for a safety tool. It led to the distinct  CEDAR_INVALID  status above.
5. "Done" isn't evidence. At one point my coding agent reported a model switch as complete, but a real Lambda log still showed the old model running because the stack had never been redeployed. After that I required pasted logs for every acceptance check instead of accepting descriptions. I now log the resolved model ID at the start of every Bedrock call so a stale deploy is visible immediately.
What I'd do next The demo uses a controlled, pre-seeded usage history on a test role, and each run is developer-triggered. The event-driven design (EventBridge → SQS) is built to extend to background evaluation, but I didn't build a daemon. Real organizational scale needs more work: incremental CloudTrail queries, batched Bedrock calls, risk-tiered approval so humans only review the risky removals, and multi-account aggregation.

Takeaways

  • Keep the AI in the suggestion seat. Deterministic checks and a human approval step make it trustworthy.
  • Know the boundary between application authorization (Cedar/AVP) and AWS-layer enforcement (IAM).
  • Design so a data source can be swapped without touching the rest of the pipeline.
  • Demand real evidence for every claim, including your own.
AI tools used: Claude for architecture planning and research; Antigravity as a coding agent. Design decisions and code review were mine.
#AWS #FirstCommit #WeMakeDevs #IAM #AmazonBedrock #CloudSecurity #Terraform #Serverless
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