与S3通信时Lambda超时 [英] Lambda Timeout while communicating with S3
问题描述
我正在尝试使用Lambda简单列出S3存储桶中的所有文件
I'm trying to simply list all the files in an S3 bucket using Lambda
代码如下:
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
exports.handler = (event, context, callback) => {
s3.listObjectsV2({
Bucket: "bucketname",
}, function(err, data) {
console.log("DONE : " + err + " : " + data);
callback(null, 'Hello from Lambda');
});
};
使用上述方法,我根本没有得到完成"的字样.日志除了超时外没有任何信息.
Using the above, I never get the "DONE" printed at all. The log doesn't show any information except for the fact that it timed out.
我可以在这里进行任何故障排除吗?我本以为至少该错误会在完成"部分中显示.
Is there any troubleshooting I could do here? I would've thought that at least the error would've been shown in the "DONE" section.
推荐答案
感谢上面的迈克尔.问题在于它正在VPC内部运行.如果我将其更改为无VPC",则它可以正常工作.如果要求它在VPC中运行,则解决方案可能会有所不同.
Thanks to Michael above. The problem was that it was running inside a VPC. If I change it to No VPC, it works correctly. Your solution may be different if you require it to run in a VPC.
这篇关于与S3通信时Lambda超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!