This pattern enables CloudTrail data plane logging for Amazon EventBridge and triggers a Lambda function when PutEvents API calls are detected, providing security and operational visibility into event bus activity.
Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/eventbridge-cloudtrail-dataplane-cdk
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details.
Note: CloudTrail data events are billed separately from management events. See AWS CloudTrail Pricing for current data event rates.
- AWS CLI installed and configured
- AWS CDK installed
- Node.js 20+ installed
- Clone and navigate to the pattern:
cd serverless-patterns/eventbridge-cloudtrail-dataplane-cdk npm install - Bootstrap CDK (first-time CDK users only):
cdk bootstrap - Deploy:
cdk deploy
- A CloudTrail trail is created with data event logging enabled for EventBridge event buses (
AWS::Events::EventBus) - EventBridge data plane API calls (PutEvents) are now logged to CloudTrail (new May 2026 feature)
- An EventBridge rule captures these CloudTrail events matching
aws.eventssource withPutEventsevent name - A Lambda function processes the events, logging the caller identity, source IP, event bus, and entry count
- This enables security teams to audit who is putting events to which bus
# Put a test event to the default event bus
aws events put-events --entries '[{"Source":"test.app","DetailType":"TestEvent","Detail":"{\"key\":\"value\"}"}]'
# Check Lambda logs (allow ~5 minutes for CloudTrail delivery)
aws logs tail /aws/lambda/$(aws cloudformation describe-stacks \
--stack-name EventbridgeCloudtrailDataplaneStack \
--query 'Stacks[0].Outputs[?OutputKey==`ProcessorFunctionName`].OutputValue' --output text) \
--followcdk destroy
Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0