AI-Powered AWS CloudTrail Security Analysis | Automated threat detection, anomaly detection, and intelligent security insights using Strands AI Agent, AWS Bedrock LLMs, and AgentCore Runtime.
The AWS CloudTrail Security AI Agent is an intelligent security monitoring solution that leverages artificial intelligence to analyze AWS CloudTrail logs and detect security threats in real-time. Built on Strands AI Agent framework and powered by AWS Bedrock's advanced language models, this tool provides automated security intelligence without requiring external dependencies.
Demo.mp4
- π€ AI-Driven Security Analysis: Automated CloudTrail log analysis using Strands AI Agent technology
- βοΈ AWS Bedrock Integration: Leverages Claude 3.5 Sonnet and other Amazon Bedrock LLMs for advanced threat detection
- π AgentCore Runtime Deployment: Fully managed agent hosting on AWS Bedrock AgentCore for production workloads
- π Real-Time Threat Detection: Identifies suspicious activity, unauthorized access attempts, and anomalous patterns
- π¬ Interactive Chat Interface: User-friendly Streamlit-based web UI for natural language security queries
- π Intelligent Insights: Generates human-readable security reports with actionable recommendations
- π οΈ Zero External Dependencies: All analysis performed using built-in AWS tools and services
- π³ Containerized Deployment: Easy setup with Docker and Docker Compose
| Component | Technology | Purpose |
|---|---|---|
| AI Agent Framework | Strands AI Agent | Orchestrates intelligent log analysis and automation |
| LLM Platform | AWS Bedrock (Claude 3.5 Sonnet) | Generative AI for security analysis and insights |
| Runtime Environment | AWS Bedrock AgentCore | Managed serverless agent hosting |
| API Layer | FastAPI | High-performance REST API service |
| Frontend Interface | Streamlit | Interactive chat-style web application |
| Data Source | AWS CloudTrail | AWS audit and governance log service |
| Containerization | Docker & Docker Compose | Simplified deployment and scalability |
- Data Collection: Retrieves CloudTrail events from specified AWS regions and timeframes
- AI Processing: Strands Agent analyzes logs using AWS Bedrock LLMs
- Pattern Recognition: Identifies access patterns, privilege escalations, and anomalies
- Intelligence Generation: Creates natural language security reports with risk assessments
- Interactive Delivery: Streams insights through conversational web interface
Before installing the AWS CloudTrail Security AI Agent, ensure you have:
- Docker (version 20.10+) and Docker Compose installed
- AWS Account with CloudTrail enabled
- AWS IAM Credentials with appropriate permissions:
- CloudTrail read access (
cloudtrail:LookupEvents) - Bedrock model access (
bedrock:InvokeModel) - AgentCore deployment permissions (optional, for production)
- CloudTrail read access (
- AWS Bedrock service enabled in your region
- Anthropic Claude 3.5 Sonnet model access (or compatible Bedrock model)
git clone https://github.com/Tarique-B-DevOps/AWS-CloudTrail-Security-AI-Agent.git
cd AWS-CloudTrail-Security-AI-AgentExport your AWS credentials and Bedrock configuration as environment variables:
export AWS_ACCESS_KEY_ID=your_access_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_access_key
export AWS_SESSION_TOKEN=your_session_token # For temporary credentials
export BEDROCK_MODEL_REGION=us-east-1
export BEDROCK_MODEL_ID=us.anthropic.claude-3-5-sonnet-20241022-v2:0Security Note: Replace placeholder values with your actual AWS credentials. For production, use IAM roles instead of hardcoded credentials.
Start all services in containerized environment:
docker compose up --buildOpen your browser and navigate to:
http://localhost:8501
The AI agent understands natural language queries about your CloudTrail logs:
analyze the usage pattern of the user tarique in us-east-1 region in last one hour
Response: The agent will stream real-time analysis including:
- API calls made by the user
- Resources accessed
- Unusual access patterns
- Potential security risks
show me any suspicious login attempts in the last 24 hours
identify any privilege escalation attempts in the last week
summarize all IAM policy changes made by admin users today
For production workloads, deploy your AI agent to AWS Bedrock AgentCore for fully managed, serverless hosting:
./deploy-on-agentcore.shThis script will:
- Package your Strands agent configuration
- Create AgentCore runtime resources
- Deploy the agent to AWS infrastructure
- Configure necessary IAM permissions
Once deployment completes, access the web UI at http://localhost:8501. The runtime indicator should show AgentCore.
Submit the same security queries. Responses will now be generated from the AgentCore runtime, providing:
- Higher Availability: Managed AWS infrastructure
- Better Performance: Optimized agent execution
- Auto-Scaling: Handles variable workloads
- Cost Efficiency: Pay only for usage
To delete AgentCore deployment and associated resources:
./deploy-on-agentcore.sh --delete| Variable | Description | Default | Required |
|---|---|---|---|
AWS_ACCESS_KEY_ID |
AWS access key | - | Yes |
AWS_SECRET_ACCESS_KEY |
AWS secret key | - | Yes |
AWS_SESSION_TOKEN |
Temporary session token | - | No |
BEDROCK_MODEL_REGION |
AWS Bedrock region | us-east-1 |
Yes |
BEDROCK_MODEL_ID |
Bedrock model identifier | Claude 3.5 Sonnet | Yes |
CLOUDTRAIL_REGION |
CloudTrail region to analyze | us-east-1 |
No |
LOG_LEVEL |
Application logging level | INFO |
No |
- β
us.anthropic.claude-3-5-sonnet-20241022-v2:0(Recommended) - β
anthropic.claude-3-sonnet-20240229-v1:0 - β
anthropic.claude-3-opus-20240229-v1:0 - β Other Bedrock-supported LLMs
- Real-time Threat Monitoring: Continuous analysis of CloudTrail logs for security events
- Incident Response: Quickly investigate suspicious activity with natural language queries
- Forensic Analysis: Historical log analysis for post-incident investigations
- Compliance Reporting: Generate audit reports for SOC 2, ISO 27001, PCI DSS
- Access Reviews: Identify and review privileged access patterns
- Change Tracking: Monitor infrastructure and configuration changes
- CI/CD Security: Integrate security checks into deployment pipelines
- Developer Activity Monitoring: Track and analyze developer actions in AWS
- Automated Security Reviews: Schedule periodic security assessments
When deploying the AWS CloudTrail Security AI Agent:
- Use IAM Roles: Prefer IAM roles over access keys for EC2/ECS deployments
- Least Privilege: Grant minimum required permissions for CloudTrail and Bedrock
- Encrypt Credentials: Store sensitive credentials in AWS Secrets Manager or Parameter Store
- Network Security: Deploy in private subnets with appropriate security groups
- Audit Logging: Enable CloudTrail for the agent's own AWS API calls
- Regular Updates: Keep dependencies and Docker images up to date