TrailTool makes auditing CloudTrail logs fast and powerful.
With TrailTool, you can:
- Correlate human and agent activity to investigate and summarize access
- Track identity across role assumptions and OAuth authorization (e.g.
aws loginand AWS MCP) - Generate least-privilege IAM policies from usage
- Detect malicious or unwanted (e.g. ClickOps) behavior
TrailTool is composed of:
- An ingestor Lambda function for parsing and correlating CloudTrail from S3.
- DynamoDB tables for persisting queryable entities: People, Sessions, Roles, Services, Resources
trailtoolCLI for accessing DynamoDB data and supporting common use cases
The ingestor is published to the Serverless Application Repository as
trailtool-ingestor, with trailtool-cloudtrail-forwarder for buckets in
another account. ingestor/README.md has CloudFormation
and Terraform examples for each step, and how to verify the setup.
S3 publishes EventBridge notifications only to the bucket owner's account, so the setup depends on where the CloudTrail bucket lives. In both, the steps can run in any order.
- Bucket: enable EventBridge notifications (see the warning below), or
deploy the ingestor with
ManageBucketNotification=trueand it does this. - Ingestor: deploy
trailtool-ingestorwithCloudTrailBucketName.
For example, an organization trail whose bucket is in a log archive account.
- Bucket owner: enable EventBridge notifications.
- Bucket owner: grant
trailtool-ingestor-roles3:GetObjectin the bucket policy. Grant the ingestor account root with anaws:PrincipalArncondition, because S3 rejects a policy naming a role that doesn't exist yet. - Ingestor account: deploy
trailtool-ingestorwithManageBucketNotification=falseandEventSourceAccount=<bucket owner account>. - Bucket owner account: deploy
trailtool-cloudtrail-forwarderwithCloudTrailBucketNameandIngestorAccountId.
Steps 3 and 4 can run in either order. Events forwarded before the ingestor's
event bus policy exists fail delivery; trailtool replay backfills them.
Warning
aws s3api put-bucket-notification-configuration replaces the bucket's whole
notification config. Fetch it with get-bucket-notification-configuration and
merge EventBridgeConfiguration in. Terraform's aws_s3_bucket_notification
with eventbridge = true likewise owns the whole config.
Requires AWS SAM CLI
cd ingestor
sam deploy --template-file template-sandbox.yaml # new trail and bucket
sam deploy --parameter-overrides CloudTrailBucketName=your-bucket # existing bucket
make deploy-org-all TRAIL_BUCKET=your-bucket BUCKET_ACCOUNT=111111111111 # cross accountbrew install engseclabs/tap/trailtoolOr with Go:
go install github.com/engseclabs/trailtool/cmd/trailtool@latest# People
trailtool people list
trailtool people detail <id>
# Sessions
trailtool sessions list
trailtool sessions detail <id>
trailtool sessions summarize <id>
trailtool sessions policy <id>
# Accounts
trailtool accounts list
trailtool accounts detail <account-id>
# Roles
trailtool roles list <id>
trailtool roles policy <id>
# Services
trailtool services list
trailtool services detail <service-name>
# Resources
trailtool resources list
trailtool resources list
trailtool resources detail <id>
# Setup diagnostics
trailtool statusAll commands support --format json for machine-readable output.
CloudTrail is a stream of independent events; sessions are an overlay TrailTool derives from latent metadata AWS stamps on those events. The goal is to tie every event back to the initiating human (or, failing that, the role).
TrailTool stitches events into sessions, gives each resulting session a session type, and records a session chain between sessions when there is role chaining, aws login, or AWS MCP Server correlation.
TYPE |
Meaning |
|---|---|
CLI |
CLI/SDK credential session |
WEB |
Console (browser) session |
AGENT |
AWS MCP Server traffic |
LOGIN |
Credentials vended to an agent via aws login |
TrailTool is designed to work well with AI coding agents like Claude Code and Cursor. To teach your agent about TrailTool's capabilities, copy docs/agent-instructions.md into your project as CLAUDE.md (or your agent's equivalent configuration file).
This gives your agent full knowledge of the CLI and step-by-step workflows for common tasks like detecting ClickOps, generating least-privilege IAM policies, and validating break-glass access.
