skip to Main Content

I am working in python and have a code that receives s3 event notifications via an SQS. I’m trying to find existing type support (for type hints and parsing using pydantic) for events such as s3:ObjectCreated – I would assume something must exist in libraries such as types_aiobotocore_s3, but I’m unable to locate a type that describes these events.
I don’t want to write it myself, because it should probably already exist.

Can anyone please assist?

2

Answers


  1. Here’s a sample S3 event. This one came from the AWS Lambda ‘Test’ function:

    {
      "Records": [
        {
          "eventVersion": "2.0",
          "eventSource": "aws:s3",
          "awsRegion": "us-east-1",
          "eventTime": "1970-01-01T00:00:00.000Z",
          "eventName": "ObjectCreated:Put",
          "userIdentity": {
            "principalId": "EXAMPLE"
          },
          "requestParameters": {
            "sourceIPAddress": "127.0.0.1"
          },
          "responseElements": {
            "x-amz-request-id": "EXAMPLE123456789",
            "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH"
          },
          "s3": {
            "s3SchemaVersion": "1.0",
            "configurationId": "testConfigRule",
            "bucket": {
              "name": "example-bucket",
              "ownerIdentity": {
                "principalId": "EXAMPLE"
              },
              "arn": "arn:aws:s3:::example-bucket"
            },
            "object": {
              "key": "test%2Fkey",
              "size": 1024,
              "eTag": "0123456789abcdef0123456789abcdef",
              "sequencer": "0A1B2C3D4E5F678901"
            }
          }
        }
      ]
    }
    

    It’s not particularly complex. Almost everything is a string.

    Login or Signup to reply.
  2. The message sent from S3 to Lambda is not generated by Boto3, so those aibotocore typings would not be relevant here. I suggest trying the S3Event type in this aws-lambda-typings library.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search