[英]Handling S3 Bucket Trigger Event in Lambda Using Python
The AWS Lambda handler has a signature of AWS Lambda处理程序具有签名
def lambda_handler(event, context):
However, I cannot find any documentation as to the event's structure when the trigger is an S3 Bucket receiving a put 但是,当触发器是S3 Bucket接收put时,我找不到有关事件结构的任何文档
I thought that it might be defined in the s3 console, but couldn't find that there. 我认为它可能在s3控制台中定义,但在那里找不到。
Anyone have any leads? 有人有任何线索吗?
The event from S3 to Lambda function will be in json format as shown below, 从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
}
]
}
here is the link for aws documentation which can guide you. 这是aws文档的链接,可以指导您。 http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html
http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html
I think your easiest route is just to experiment quickly: 我认为您最简单的方法就是快速实验:
You'll then see the event structure in the log - its pretty self explanatory. 然后,您将在日志中看到事件结构 - 它非常自我解释。
请参阅此URL以获取事件消息结构: http : //docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.