Skip to content

(aws-events): add enhanced logging support to EventBus #35000

@garysassano

Description

@garysassano

Describe the feature

AWS CDK should support the new EventBridge Event Buses logging capability. This is similar to the EventBridge Pipes logging capability added a couple of years ago.

Use Case

With the new EventBridge enhanced logging capability, developers can now monitor and debug event-driven applications with comprehensive logs that provide visibility into the complete event journey. This addresses microservices and event-driven architecture monitoring challenges by providing detailed event lifecycle tracking.

Proposed Solution

Add logging configuration support to the EventBus construct in the aws-events module, following the proven design patterns from the EventBridge Pipes alpha module (@aws-cdk/aws-pipes-alpha) to ensure consistency across EventBridge services.

Proposed API Design

import * as events from 'aws-cdk-lib/aws-events';
import * as logs from 'aws-cdk-lib/aws-logs';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as firehose from 'aws-cdk-lib/aws-kinesisfirehose';

// Create an event bus with logging configuration
const logGroup = new logs.LogGroup(this, 'EventBridgeLogGroup');

const eventBus = new events.EventBus(this, 'MyEventBus', {
  eventBusName: 'my-custom-bus',
  logDestinations: [
    new events.CloudwatchLogsLogDestination(logGroup)
  ],
  logLevel: events.LogLevel.INFO,
  logIncludeExecutionData: [events.IncludeExecutionData.ALL]
});

// Configure multiple log destinations
const s3Bucket = new s3.Bucket(this, 'LogBucket');
const deliveryStream = new firehose.DeliveryStream(this, 'LogStream', {
  destination: new firehose.S3Bucket(s3Bucket)
});

eventBus.configureLogging({
  logDestinations: [
    new events.CloudwatchLogsLogDestination(logGroup),
    new events.S3LogDestination({
      bucket: s3Bucket,
      prefix: 'eventbridge-logs/',
      outputFormat: events.S3OutputFormat.JSON
    }),
    new events.FirehoseLogDestination(deliveryStream)
  ],
  logLevel: events.LogLevel.ERROR,
  logIncludeExecutionData: [events.IncludeExecutionData.ALL]
});

Supported Features

Log Destinations:

  • CloudWatch Logs
  • Amazon S3
  • Kinesis Data Firehose

Log Levels:

  • OFF
  • ERROR
  • INFO
  • TRACE

Configuration Options:

  • Include execution data (event payloads) with privacy control
  • Multiple destination support
  • Encryption support (customer-managed keys)

Implementation Details

Generate CloudFormation properties mapping to EventBridge logging API parameters: LoggingConfiguration.LogDestination, LoggingConfiguration.LogLevel, and LoggingConfiguration.IncludeExecutionData.

Key patterns to adopt:

  1. ILogDestination interface with bind() and grantPush() methods
  2. Separate destination classes (CloudwatchLogsLogDestination, FirehoseLogDestination, S3LogDestination)
  3. Configuration enums (LogLevel, IncludeExecutionData, S3OutputFormat)
  4. IAM permission management through grantPush() method
  5. CloudFormation property mapping through bind() method

Rationale: EventBridge Event Buses and Pipes share identical logging requirements (same destinations, same service family), making the Pipes alpha module the logical foundation for consistent developer experience across EventBridge constructs.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS CDK Library version (aws-cdk-lib)

2.206.0

AWS CDK CLI version

2.1021.0

Environment details (OS name and version, etc.)

Ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-eventsRelated to CloudWatch Eventseffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions