-
Notifications
You must be signed in to change notification settings - Fork 432
feat(parser): add support for SQS-wrapped S3 event notifications #2108
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
leandrodamascena
merged 15 commits into
aws-powertools:develop
from
theipster:s3-event-notification-model
May 2, 2023
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
502ce6d
Introduce model for SQS-wrapped S3 event notifications
theipster 72b127d
Export SqsS3EventNotificationModel
theipster a13e190
Merge branch 'develop' into s3-event-notification-model
theipster 665a99d
Re-order exports into (slightly more) alphabetical order
theipster 6c426dd
Differentiate between *RecordModel vs *Model
theipster be69e4c
Add positive functional tests for SqsS3EventNotificationModel
theipster ad2ba2c
Silly me, I may have overcomplicated this...
theipster 70e7b1c
Fix formatting
theipster 251d8ba
Add negative functional tests for SqsS3EventNotificationModel
theipster 1116552
Explicitly import local method
theipster 598b90d
Merge remote-tracking branch 'upstream/develop' into s3-event-notific…
leandrodamascena 31eaa2e
parser(sqs3): fixing mypy errors and adding documentation
leandrodamascena f118583
parser(sqs3): improving documentation, refactoring classname and tests
leandrodamascena 26cf2b7
tests: addressing Ruben's feedback
leandrodamascena 9c759d7
Merge branch 'develop' into s3-event-notification-model
leandrodamascena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
aws_lambda_powertools/utilities/parser/models/s3_event_notification.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import List | ||
|
||
from pydantic import Json | ||
|
||
from aws_lambda_powertools.utilities.parser.models.s3 import S3Model | ||
from aws_lambda_powertools.utilities.parser.models.sqs import SqsModel, SqsRecordModel | ||
|
||
|
||
class S3SqsEventNotificationRecordModel(SqsRecordModel): | ||
body: Json[S3Model] | ||
|
||
|
||
class S3SqsEventNotificationModel(SqsModel): | ||
Records: List[S3SqsEventNotificationRecordModel] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,25 +156,26 @@ def my_function(): | |
|
||
Parser comes with the following built-in models: | ||
|
||
| Model name | Description | | ||
| --------------------------------------- | ---------------------------------------------------------------------------- | | ||
| **DynamoDBStreamModel** | Lambda Event Source payload for Amazon DynamoDB Streams | | ||
| **EventBridgeModel** | Lambda Event Source payload for Amazon EventBridge | | ||
| **SqsModel** | Lambda Event Source payload for Amazon SQS | | ||
| **AlbModel** | Lambda Event Source payload for Amazon Application Load Balancer | | ||
| **CloudwatchLogsModel** | Lambda Event Source payload for Amazon CloudWatch Logs | | ||
| **S3Model** | Lambda Event Source payload for Amazon S3 | | ||
| **S3ObjectLambdaEvent** | Lambda Event Source payload for Amazon S3 Object Lambda | | ||
| **S3EventNotificationEventBridgeModel** | Lambda Event Source payload for Amazon S3 Event Notification to EventBridge. | | ||
| **KinesisDataStreamModel** | Lambda Event Source payload for Amazon Kinesis Data Streams | | ||
| **KinesisFirehoseModel** | Lambda Event Source payload for Amazon Kinesis Firehose | | ||
| **SesModel** | Lambda Event Source payload for Amazon Simple Email Service | | ||
| **SnsModel** | Lambda Event Source payload for Amazon Simple Notification Service | | ||
| **APIGatewayProxyEventModel** | Lambda Event Source payload for Amazon API Gateway | | ||
| **APIGatewayProxyEventV2Model** | Lambda Event Source payload for Amazon API Gateway v2 payload | | ||
| **LambdaFunctionUrlModel** | Lambda Event Source payload for Lambda Function URL payload | | ||
| **KafkaSelfManagedEventModel** | Lambda Event Source payload for self managed Kafka payload | | ||
| **KafkaMskEventModel** | Lambda Event Source payload for AWS MSK payload | | ||
| Model name | Description | | ||
| --------------------------------------- | ------------------------------------------------------------------------------------- | | ||
| **AlbModel** | Lambda Event Source payload for Amazon Application Load Balancer | | ||
| **APIGatewayProxyEventModel** | Lambda Event Source payload for Amazon API Gateway | | ||
| **APIGatewayProxyEventV2Model** | Lambda Event Source payload for Amazon API Gateway v2 payload | | ||
| **CloudwatchLogsModel** | Lambda Event Source payload for Amazon CloudWatch Logs | | ||
| **DynamoDBStreamModel** | Lambda Event Source payload for Amazon DynamoDB Streams | | ||
| **EventBridgeModel** | Lambda Event Source payload for Amazon EventBridge | | ||
| **KafkaMskEventModel** | Lambda Event Source payload for AWS MSK payload | | ||
| **KafkaSelfManagedEventModel** | Lambda Event Source payload for self managed Kafka payload | | ||
| **KinesisDataStreamModel** | Lambda Event Source payload for Amazon Kinesis Data Streams | | ||
| **KinesisFirehoseModel** | Lambda Event Source payload for Amazon Kinesis Firehose | | ||
| **LambdaFunctionUrlModel** | Lambda Event Source payload for Lambda Function URL payload | | ||
| **S3EventNotificationEventBridgeModel** | Lambda Event Source payload for Amazon S3 Event Notification to EventBridge. | | ||
| **S3Model** | Lambda Event Source payload for Amazon S3 | | ||
| **S3ObjectLambdaEvent** | Lambda Event Source payload for Amazon S3 Object Lambda | | ||
| **S3SqsEventNotificationModel** | Lambda Event Source payload for S3 event notifications wrapped in SQS event (S3->SQS) | | ||
| **SesModel** | Lambda Event Source payload for Amazon Simple Email Service | | ||
| **SnsModel** | Lambda Event Source payload for Amazon Simple Notification Service | | ||
| **SqsModel** | Lambda Event Source payload for Amazon SQS | | ||
Comment on lines
+159
to
+178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took the opportunity to organize the names of the models in alphabetical order. |
||
|
||
#### Extending built-in models | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"Records":[ | ||
{ | ||
"messageId":"ca3e7a89-c358-40e5-8aa0-5da01403c267", | ||
"receiptHandle":"AQEBE7XoI7IQRLF7SrpiW9W4BanmOWe8UtVDbv6/CEZYKf/OktSNIb4j689tQfR4k44V/LY20lZ5VpxYt2GTYCsSLKTcBalTJaRX9CKu/hVqy/23sSNiKxnP56D+VLSn+hU275+AP1h4pUL0d9gLdRB2haX8xiM+LcGfis5Jl8BBXtoxKRF60O87O9/NvCmmXLeqkJuexfyEZNyed0fFCRXFXSjbmThG0OIQgcrGI8glBRGPA8htns58VtXFsSaPYNoqP3p5n6+ewKKVLD0lfm+0DlnLKRa+mjvFBaSer9KK1ff+Aq6zJ6HynPwADj+aF70Hwimc2zImYe51SLEF/E2csYlMNZYI/2qXW0m9R7wJ/XDTV4g2+h+BMTxsKnJQ6NQd", | ||
"body":"{\"Records\":[{\"eventVersion\":\"2.1\",\"eventSource\":\"aws:s3\",\"awsRegion\":\"us-east-1\",\"eventTime\":\"2023-04-12T20:43:38.021Z\",\"eventName\":\"ObjectCreated:Put\",\"userIdentity\":{\"principalId\":\"A1YQ72UWCM96UF\"},\"requestParameters\":{\"sourceIPAddress\":\"93.108.161.96\"},\"responseElements\":{\"x-amz-request-id\":\"YMSSR8BZJ2Y99K6P\",\"x-amz-id-2\":\"6ASrUfj5xpn859fIq+6FXflOex/SKl/rjfiMd7wRzMg/zkHKR22PDpnh7KD3uq//cuOTbdX4DInN5eIs+cR0dY1z2Mc5NDP/\"},\"s3\":{\"s3SchemaVersion\":\"1.0\",\"configurationId\":\"SNS\",\"bucket\":{\"name\":\"xxx\",\"ownerIdentity\":{\"principalId\":\"A1YQ72UWCM96UF\"},\"arn\":\"arn:aws:s3:::xxx\"},\"object\":{\"key\":\"test.pdf\",\"size\":104681,\"eTag\":\"2e3ad1e983318bbd8e73b080e2997980\",\"versionId\":\"yd3d4HaWOT2zguDLvIQLU6ptDTwKBnQV\",\"sequencer\":\"00643717F9F8B85354\"}}}]}", | ||
"attributes":{ | ||
"ApproximateReceiveCount":"1", | ||
"SentTimestamp":"1681332219270", | ||
"SenderId":"AIDAJHIPRHEMV73VRJEBU", | ||
"ApproximateFirstReceiveTimestamp":"1681332239270" | ||
}, | ||
"messageAttributes":{ | ||
|
||
}, | ||
"md5OfBody":"16f4460f4477d8d693a5abe94fdbbd73", | ||
"eventSource":"aws:sqs", | ||
"eventSourceARN":"arn:aws:sqs:us-east-1:123456789012:SQS", | ||
"awsRegion":"us-east-1" | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.