Skip to content

feat(event_source): export SQSRecord in data_classes module #6639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aws_lambda_powertools/utilities/data_classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from .secrets_manager_event import SecretsManagerEvent
from .ses_event import SESEvent
from .sns_event import SNSEvent
from .sqs_event import SQSEvent
from .sqs_event import SQSEvent, SQSRecord
from .transfer_family_event import TransferFamilyAuthorizer, TransferFamilyAuthorizerResponse
from .vpc_lattice import VPCLatticeEvent, VPCLatticeEventV2

Expand Down Expand Up @@ -87,6 +87,7 @@
"SESEvent",
"SNSEvent",
"SQSEvent",
"SQSRecord",
"event_source",
"AWSConfigRuleEvent",
"VPCLatticeEvent",
Expand Down
11 changes: 8 additions & 3 deletions examples/event_sources/src/sqs_event.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from aws_lambda_powertools.utilities.data_classes import SQSEvent, event_source
from aws_lambda_powertools.utilities.data_classes import SQSEvent, SQSRecord, event_source


@event_source(data_class=SQSEvent)
def lambda_handler(event: SQSEvent, context):
# Multiple records can be delivered in a single event
for record in event.records:
message = record.body
message_id = record.message_id
message, message_id = process_record(record)
return {
"message": message,
"message_id": message_id,
}


def process_record(record: SQSRecord):
message = record.body
message_id = record.message_id
return message, message_id
Loading