[英]Handling S3 Bucket Trigger Event in Lambda Using Python
AWS Lambda处理程序具有签名
def lambda_handler(event, context):
但是,当触发器是S3 Bucket接收put时,我找不到有关事件结构的任何文档
我认为它可能在s3控制台中定义,但在那里找不到。
有人有任何线索吗?
从S3到Lambda函数的事件将采用json格式,如下所示,
{
"Records":[
{
"eventVersion":"2.0",
"eventSource":"aws:s3",
"awsRegion":"us-east-1",
"eventTime":The time, in ISO-8601 format, for example, 1970-01-01T00:00:00.000Z, when S3 finished processing the request,
"eventName":"event-type",
"userIdentity":{
"principalId":"Amazon-customer-ID-of-the-user-who-caused-the-event"
},
"requestParameters":{
"sourceIPAddress":"ip-address-where-request-came-from"
},
"responseElements":{
"x-amz-request-id":"Amazon S3 generated request ID",
"x-amz-id-2":"Amazon S3 host that processed the request"
},
"s3":{
"s3SchemaVersion":"1.0",
"configurationId":"ID found in the bucket notification configuration",
"bucket":{
"name":"bucket-name",
"ownerIdentity":{
"principalId":"Amazon-customer-ID-of-the-bucket-owner"
},
"arn":"bucket-ARN"
},
"object":{
"key":"object-key",
"size":object-size,
"eTag":"object eTag",
"versionId":"object version if bucket is versioning-enabled, otherwise null",
"sequencer": "a string representation of a hexadecimal value used to determine event sequence,
only used with PUTs and DELETEs"
}
}
},
{
// Additional events
}
]
}
这是aws文档的链接,可以指导您。 http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html
我认为您最简单的方法就是快速实验:
然后,您将在日志中看到事件结构 - 它非常自我解释。
请参阅此URL以获取事件消息结构: http : //docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.