Skip to content

feat(data_classes,parser): add EventBridge Custom Event Bus support - #8658

Merged
leandrodamascena merged 2 commits into
aws-powertools:developfrom
Asymtode712:feat/eventbridge-custom-event-bus
Oct 25, 2026
Merged

leandrodamascena merged 2 commits into
aws-powertools:developfrom
Asymtode712:feat/eventbridge-custom-event-bus

Conversation

@Asymtode712

Copy link
Copy Markdown
Contributor

Issue number: closes #8657

Summary

Changes

Adds support for the payloads delivered by the new Amazon EventBridge Custom Event Bus to Lambda:

  • EventBridgeV2Event data class (records, EventBridgeV2Record, EventBridgeV2SystemMetadata) accepting a single object or an array, WITH_METADATA (Data/Metadata/SystemMetadata) and RAW deliveries (classic envelope, PutEvents array, bare PutRawEvents payload). Exposes data (bytes for application/octet-stream), detail, metadata and system_metadata (event_id, sequence_number, delivery_type, event_group_id, deduplication_id, content_type, ingestion_time, source, detail_type).
  • EventBridgeV2Model (single or list, via a root model) for WITH_METADATA payloads.
  • EventBridgeV2Envelope returning a list with the Data of each record (or Data.detail for PutEvents) parsed into the user model.
  • Docs, example, test event and unit tests.

Partial batch failure / Batch integration is out of scope until the service documents a usable identifier.

User experience

Before: EventBridgeEvent / EventBridgeModel fail on the Custom Event Bus default delivery (array), WITH_METADATA and PutRawEvents payloads (TypeError, KeyError).

After:

from aws_lambda_powertools.utilities.data_classes import EventBridgeV2Event, event_source

@event_source(data_class=EventBridgeV2Event)
def handler(event: EventBridgeV2Event, context):
    for record in event.records:
        if record.system_metadata.delivery_type == "REPLAY":
            continue
        record.data, record.detail, record.metadata, record.system_metadata.event_id
from aws_lambda_powertools.utilities.parser import parse, envelopes

orders: list[Order] = parse(event=event, model=Order, envelope=envelopes.EventBridgeV2Envelope)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@Asymtode712
Asymtode712 requested a review from a team as a code owner October 25, 2026 12:38
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 25, 2026
@boring-cyborg boring-cyborg Bot added documentation Improvements or additions to documentation tests labels Oct 25, 2026
@boring-cyborg

boring-cyborg Bot commented Oct 25, 2026

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 25, 2026

@leandrodamascena leandrodamascena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Asymtode712, that was quick, and it holds up. I rebuilt a real Custom Event Bus with eight subscriber variants, RAW and WITH_METADATA, batched and single, FIFO with two groups, PutRawEvents with JSON and application/octet-stream, plus a replay subscriber, all delivering to a Lambda running this branch. The data class got every one of them right, including bytes for octet-stream, event_group_id per record and delivery_type="REPLAY" on the replayed batch. The envelope parsed every JSON delivery into the user model.

I pushed three small things so we don't need another round: the doc link now points to eb-custom-bus.html (the old one redirects to the guide root), the envelope decodes Data when it comes as bytes so the JSON path handles it, and the three aws: fields the service doesn't guarantee are optional in the model.

Approving. This goes out in 3.38.0, so it will sit here briefly before I merge it. No rebase needed, and you'll be credited in the release notes.

@leandrodamascena leandrodamascena added this to the 3.38.0 milestone Oct 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

@leandrodamascena
leandrodamascena merged commit 5785377 into aws-powertools:develop Oct 25, 2026
15 checks passed
@boring-cyborg

boring-cyborg Bot commented Oct 25, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@powertools-for-aws-oss-automation

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.40000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.95%. Comparing base (45f7a4d) to head (b272525).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...ertools/utilities/parser/models/event_bridge_v2.py 94.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8658      +/-   ##
===========================================
+ Coverage    96.94%   96.95%   +0.01%     
===========================================
  Files          318      321       +3     
  Lines        16121    16246     +125     
  Branches      1445     1453       +8     
===========================================
+ Hits         15628    15751     +123     
- Misses         352      353       +1     
- Partials       141      142       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: support the new EventBridge Custom Event Bus payloads in data classes and Parser

2 participants