AWS Lambda处理程序具有
的签名def lambda_handler(event, context):
但是,当触发器是S3 Bucket接收放置时,我找不到关于事件结构的任何文档
我认为它可能在s3控制台中定义,但在那里找不到。
任何人都有任何线索?
答案 0 :(得分:6)
从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
答案 1 :(得分:1)
我认为您最简单的方法就是快速试验:
然后,您将在日志中看到事件结构 - 它非常自我解释。
答案 2 :(得分:-1)