我正在使用AWS Lambda將s3 bucket中的圖像調整爲使用節點js的不同大小變體,當圖像放入s3 bucket時。AWS Lambda不能與gm模塊一起使用
它一直工作到昨天。今天當我使用相同的lambda函數時,出現以下錯誤:
{
"errorMessage": "Command failed: identify: not authorized `//bucketname.s3.amazonaws.com/imagename.jpg' @ error/constitute.c/ReadImage/454.\n",
"errorType": "Error",
"stackTrace": [
"",
"ChildProcess.proc.on.onExit (/var/task/node_modules/gm/lib/command.js:297:17)",
"emitTwo (events.js:87:13)",
"ChildProcess.emit (events.js:172:7)",
"maybeClose (internal/child_process.js:821:16)",
"Socket.<anonymous> (internal/child_process.js:319:11)",
"emitOne (events.js:77:13)",
"Socket.emit (events.js:169:7)",
"Pipe._onclose (net.js:469:12)"
]
}
我無法理解爲什麼會出現這種現象。下面我的lambda函數的所有給定函數都在async waterfall中,首先計算寬高比,然後將圖像轉換爲不同大小的變體。
var request=require("request");
function getTheAspectRatio(callback) {
gm(s3Url) // I am constructing the image url in the AWS Lambda Function.
.size(function(err, size) {
if (!err) {
//Calculate the Aspect ratio
} else if (err) {
//Give Back the Error
}
});
}
function getTheImageBuffer(callback) {
request(imageUrl, function(err, res, res1) {
if (err) {
callback(err);
} else {
buffer = res1;
console.log("got the BUffer");
callback(null);
}
});
}
function convertToThumbNail(callback) {
//Convert to Thumbnail Image
}
function convertToFull(callback) {
//Convert to Full Image
}
function convertToBadge(callback) {
//Convert to Badge image
}
有人可以幫助調試該問題嗎?在過去的3個小時裏,我有點困惑。我的AWS Lambda在東京地區。
從簡單閱讀錯誤消息看來,Lambda函數不再有權訪問S3存儲桶。 –