AWS Builder Center
Weekend Agent Challenge: IAM Security Sentinel

Weekend Agent Challenge: IAM Security Sentinel

Discover how to build a fully automated cloud security agent that leverages event-driven architecture and generative AI to instantly audit new permission policies. Operating entirely within the AWS Free Tier, this background companion flags high-risk wildcard vulnerabilities and delivers immediate email alerts straight to your inbox.

AWS Certified Solutions Architect | AIF-C01 | Cloud & DevOps

Vision & What the Agent Does

When teams work in AWS, they need to create permissions called IAM policies so their applications can talk to different services. Often, to save time or fix an error quickly, people create dangerous policies. They use wildcards like  *  for actions and resources. This means they are accidentally giving away full admin access to their entire AWS account. Checking these permissions manually takes too much time, and mistakes slip through easily.
The IAM Security Sentinel is an intelligent assistant that watches your AWS account completely on its own. It does not wait for you to click a button or open a dashboard. Instead, it runs silently in the background. The exact second a user or a script creates a new IAM policy, this agent wakes up instantly.
The agent takes the policy text, reads it, and sends it to an artificial intelligence model to check for security risks. If the policy follows good security practices, the agent goes back to sleep without bothering you. But if the AI finds a dangerous loophole—like a wildcard that gives too much power—it immediately drafts a security alert. It then sends this alert straight to your email inbox, explaining exactly why the policy is unsafe and how to fix it. This keeps your cloud environment safe while you sleep.

AWS Services Used / Architecture Overview

This project is built using simple, serverless AWS services. Because it uses modern, event-driven components, it fits completely inside the AWS Free Tier.
[AWS IAM Console] ───► (CloudTrail API Event Log)
│
▼
[Amazon EventBridge Rule]
│
▼ (Auto-Trigger)
[AWS Lambda Function] ───► [Amazon Bedrock (Nova Lite AI)]
│
▼ (If Risk Found)
[Amazon SNS Topic] ───► [Your Email Inbox]

Here is how the services work together:
  • AWS CloudTrail: Automatically records every single action taken in the AWS account, like when someone makes a new permission rule.
  • Amazon EventBridge: The trigger system. It watches the CloudTrail logs specifically for two actions:  CreatePolicy  and  PutUserPolicy .
  • AWS Lambda: The brain of the operation. It runs a simple Python script whenever EventBridge tells it to. It extracts the raw permission data and handles the communication.
  • Amazon Bedrock (Nova Lite): The AI reviewer. It reads the policy and decides if it is safe or dangerous.
  • Amazon SNS (Simple Notification Service): The messenger. It takes the text warning written by the AI and emails it out immediately.
eventbridge image


How You Built It

I chose to build this entire project manually using the AWS Management Console dashboard. This gave me great hands-on practice with real cloud configurations.
First, I created an Amazon SNS topic and subscribed my personal email address to it. Next, I set up a custom IAM execution role for my Lambda function. I wrote a specific security policy that grants the Lambda function permission only to invoke Amazon Bedrock models and publish messages to my SNS topic.
Lambda Configuration

After creating the role, I wrote the automation logic using Python 3.12 inside the AWS Lambda editor. One major challenge I ran into was that the AI needs a few seconds to analyze the code and think. The default AWS Lambda timeout is only 3 seconds, which caused the function to stop before the AI finished its sentence. I easily fixed this by going into the general settings and increasing the function timeout to 30 seconds. Finally, I connected the EventBridge trigger using the updated AWS event pattern form.

Learnings

Building this autonomous agent taught me a lot about event-driven security practices. I learned how to use the modern  converse()  API in the AWS Python SDK (Boto3), which makes sending prompts to foundational models clean and straightforward. I also got to see firsthand how AWS has updated its serverless infrastructure. For example, manual model activation pages are a thing of the past; modern serverless models like Nova Lite are ready to use out of the box the moment you invoke them in code.
Most importantly, this project reinforced the concept of least privilege. By making an agent that calls out bad security policies automatically, I learned how to design reactive security guards that protect infrastructure without slowing down developers.

Link to App or Repo

Email Proof

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