简体   繁体   English

AWS S3 存储桶通知 lambda 抛出异常(服务:Amazon S3;状态代码:404;错误代码:NoSuchKey)

[英]AWS S3 bucket notification lambda throws exception (Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey)

We have a AWS Glue DataBrew job which puts the output to some S3 bucket folder.我们有一个 AWS Glue DataBrew 作业,它将输出放入某个 S3 存储桶文件夹。 Then a java lambda is notified for this Put notification.然后 java lambda 会收到此 Put 通知的通知。 But the following sample code throws exception:但是下面的示例代码抛出异常:

S3EventNotification.S3EventNotificationRecord record = event.getRecords().get(0);
String s3Bucket = record.getS3().getBucket().getName();
String s3Key= record.getS3().getObject().getUrlDecodedKey();

//following throws exception --404 NoSuchKey //下面抛出异常--404 NoSuchKey

S3Object s3object = s3Client.getObject(s3Bucket , s3Key);

When seen in logs we see that the key is something like:当在日志中看到时,我们看到密钥类似于:

**input_files/processed_file_22Dec2022_1671678897600/fdg629ae-4f91-4869-891c-79200772fb92/databrew-test-put-object.temp **input_files/processed_file_22Dec2022_1671678897600/fdg629ae-4f91-4869-891c-79200772fb92/databrew-test-put-object.temp

So is it that the, lambda gets the file which is still being copied into the S3 folder?.那么,lambda 是否获取了仍在复制到 S3 文件夹中的文件? When we upload the file manually using the console, it works fine.当我们使用控制台手动上传文件时,它工作正常。 But when databrew job uploads it, we are seeing issues.但是当 databrew 作业上传它时,我们看到了问题。

I expect the file to be read by lambda function with the correct key.我希望 lambda 函数使用正确的密钥读取该文件。

Thanks谢谢

What is your trigger event type?您的触发事件类型是什么?

So is it that the, lambda gets the file which is still being copied into the S3 folder?那么,lambda 是否获取了仍在复制到 S3 文件夹中的文件?

If you have a Put trigger, Lambda will get triggered when the object upload completes.如果您有 Put 触发器,Lambda 将在对象上传完成时被触发。 S3 wouldn't create a temporary object and then delete it. S3 不会创建临时对象然后将其删除。

I haven't used AWS Glue DataBrew before but perhaps that is creating that temporary object?我之前没有使用过 AWS Glue DataBrew,但也许这是在创建临时对象? If that is the case, you need to handle it in your code.如果是这种情况,您需要在代码中处理它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM