Skip to content

Commit

Permalink
feat: add trigger bucket event s3
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardoc-lima committed Aug 28, 2024
1 parent ee71442 commit 445fc7c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions faster_sam/dependencies/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,33 @@ def dep(message: schema) -> Dict[str, Any]:
return event

return dep


async def s3(request: Request) -> Dict[str, Any]:
body = await request.body()
event = {
"Records": [
{
"eventVersion": "2.0",
"eventSource": "aws:s3",
"awsRegion": None,
"eventTime": body["timeCreated"],
"eventName": "s3:ObjectCreated:*",
"s3": {
"s3SchemaVersion": "1.0",
"bucket": {
"name": body["bucket"],
"arn": f"arn:aws:s3:::{body['bucket']}",
},
"object": {
"key": body["name"],
"size": body["size"],
"eTag": body["etag"],
"sequencer": uuid.uuid4().int,
},
},
}
]
}

return event

0 comments on commit 445fc7c

Please sign in to comment.