Skip to content

Conversation

@oyiz-michael
Copy link
Contributor

Issue number: closes #7443

Summary

Changes

This PR adds support for parsing S3 IntelligentTiering events, which have a different structure than standard S3 events.

Root cause: S3 IntelligentTiering events use "get_object" as the key name instead of "object" in the S3 message, and include an intelligentTieringEventData field with access tier information. The existing models only supported the "object" key, causing parsing failures.

Solution: Updated both parser models and data classes to handle both field names, making the implementation backward compatible with all existing S3 event types.

Files changed:

  • aws_lambda_powertools/utilities/parser/models/s3.py: Added S3EventRecordIntelligentTieringEventData model, updated S3Message to support both object and get_object fields, and fixed validator
  • aws_lambda_powertools/utilities/data_classes/s3_event.py: Added S3EventRecordIntelligentTieringEventData class, updated S3Message.get_object() and S3Event.object_key to handle both key names
  • tests/events/s3EventIntelligentTiering.json: Added comprehensive test event
  • tests/unit/parser/_pydantic/test_s3_intelligent_tiering.py: Added parser model tests (2 tests)
  • tests/unit/data_classes/required_dependencies/test_s3_intelligent_tiering_event.py: Added data classes tests (3 tests)

User experience

Before:

from aws_lambda_powertools.utilities.data_classes import S3Event
from aws_lambda_powertools.utilities.parser import parse

# IntelligentTiering events would fail to parse
@event_source(data_class=S3Event)
def handler(event: S3Event, context):
    # Would raise KeyError: 'object'
    object_key = event.object_key
    
# Parser would also fail
def handler(event, context):
    # Would fail validation
    parsed = parse(event, model=S3Model)

After

from aws_lambda_powertools.utilities.data_classes import S3Event
from aws_lambda_powertools.utilities.parser import parse

# IntelligentTiering events now parse correctly
@event_source(data_class=S3Event)
def handler(event: S3Event, context):
    # Works with both standard S3 events and IntelligentTiering events
    object_key = event.object_key  
    
    # Access IntelligentTiering-specific data
    if event.record.intelligent_tiering_event_data:
        tier = event.record.intelligent_tiering_event_data.destination_access_tier
        # tier will be "ARCHIVE_ACCESS" or "DEEP_ARCHIVE_ACCESS"
    
# Parser also works
def handler(event, context):
    parsed = parse(event, model=S3Model)  
    record = parsed.Records[0]
    
    if record.intelligentTieringEventData:
        tier = record.intelligentTieringEventData.destinationAccessTier

All existing S3 event types continue to work as before - the changes are fully backward compatible.

Testing:

Added 5 new tests covering both parser models and data classes
All 17 S3-related tests pass (5 new + 12 existing)
No regressions in existing S3 event parsing


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.

Relates to aws-powertools#7443

S3 IntelligentTiering events use a different structure than standard
S3 events - they use 'get_object' as the key name instead of 'object'
in the S3 message, and include 'intelligentTieringEventData' field.

Changes:
- Add S3EventRecordIntelligentTieringEventData model
- Update S3Message to support both 'object' and 'get_object' fields
- Add intelligentTieringEventData field to S3RecordModel
- Update validator to handle both field names
Relates to aws-powertools#7443

Extends S3Event data classes to handle IntelligentTiering events
which use 'get_object' key instead of 'object' in the S3 message.

Changes:
- Add S3EventRecordIntelligentTieringEventData wrapper class
- Update S3Message.get_object() to handle both key names
- Update S3Event.object_key to handle both key names
- Add intelligent_tiering_event_data property to S3EventRecord
Relates to aws-powertools#7443

Add test event and comprehensive test coverage for both parser models
and data classes handling of S3 IntelligentTiering events.

Changes:
- Add s3EventIntelligentTiering.json test event
- Add parser model tests (2 tests)
- Add data classes tests (3 tests)
- Tests verify get_object field handling and intelligentTieringEventData
@oyiz-michael oyiz-michael requested a review from a team as a code owner January 19, 2026 20:09
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 19, 2026
@boring-cyborg boring-cyborg bot added the tests label Jan 19, 2026
@sonarqubecloud
Copy link

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

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: How are IntelligentTiering events meant to be parsed?

1 participant