Bug: S3Model not compatible with ObjectRemoved events
See original GitHub issueExpected Behaviour
After deleting an object from S3, if a Lambda catches this event, they should be able to parse it. This event name from S3 is ObjectDeleted:*
.
Current Behaviour
A ValidationError
is thrown because of the missing size
and eTag
attributes.
Records -> 0 -> s3 -> object -> size
field required (type=value_error.missing)
Records -> 0 -> s3 -> object -> eTag
field required (type=value_error.missing)
The ObjectDeleted
event does not include those attributes.
Code snippet
parse(model=S3Model, event=json.loads(s3_message))
Payload Example: https://github.com/awslabs/aws-lambda-powertools-python/issues/1637#issuecomment-1288170059
Possible Solution
Update S3Object
so that both size
and eTag
are optional:
class S3Object(BaseModel):
key: str
size: Optional[NonNegativeFloat]
eTag: Optional[str]
sequencer: str
versionId: Optional[str]
Steps to Reproduce
- Create a Lambda function and an S3 bucket
- Trigger the Lambda function through S3 events, and enable the
ObjectDeleted
type - Delete an object from S3
S3Model
will raise aValidationError
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.8
Packaging format used
PyPi
Debugging logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:20 (18 by maintainers)
Top Results From Across the Web
Resolve “Configuration is ambiguously defined” error ... - AWS
I'm trying to create an Amazon Simple Storage Service (Amazon S3) bucket event notification to trigger my AWS Lambda function.
Read more >[S3] Support Multiple S3 Object Notification Event Types for a ...
I need to have an SQS Queue or SNS Topic which receives both Object Created events as well as Object Deleted Events.
Read more >Event notification types and destinations - 亚马逊云科技
Amazon S3 supports several event notification types and destinations where the notifications can be published. You can specify the event type and destination ......
Read more >Terraform s3 event notification error - Stack Overflow
If you haven't done it already, you need to specify a policy on the topic that grants the SNS:Publish permission to S3 (only...
Read more >AWS S3 Bucket: Event Notifications | by Priyam Chauhan
Supported Events : Notifications could be published for following events: Object Creation ... s3:ObjectRemoved:* (All object removal events).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@heitorlessa done, the PR should be available now: PR#1638. I couldn’t really test the change right now, but if strictly needed I can fully test it tomorrow.
@barreeeiroo yeah that makes sense! nice one. I’ll open a PR with tests in a few min.