我无法在 python 中找到 aws s3 事件通知的类型

问题描述 投票:0回答:1

我正在使用 python 工作,并且有一个通过 SQS 接收 s3 事件通知的代码。我正在尝试为 s3:ObjectCreated 等事件找到现有类型支持(用于类型提示和使用 pydantic 进行解析) - 我假设某些内容必须存在于诸如 types_aiobotocore_s3 之类的库中,但我无法找到描述这些事件的类型事件。 我不想自己写它,因为它可能已经存在了。

有人可以帮忙吗?

python amazon-web-services amazon-s3 types boto3
1个回答
0
投票

这是一个 S3 事件示例。这个来自 AWS Lambda“测试”函数:

{
  "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"
        }
      }
    }
  ]
}

并不是特别复杂。几乎所有东西都是字符串。

© www.soinside.com 2019 - 2024. All rights reserved.