[英]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.