Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

amazon web services - AWS Lambda not working along with the gm module

I am using AWS Lambda to resize my image in s3 bucket into different size variants using node js when an image is put into the s3 bucket.

It was working till yesterday. Today when I use the same lambda function I get the following error:

{
"errorMessage": "Command failed: identify: not authorized `//bucketname.s3.amazonaws.com/imagename.jpg' @ error/constitute.c/ReadImage/454.
",
"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)"
    ]
}

I am unable to understand why this phenomenon occurred. All the given functions of my lambda function below are in async waterfall to first compute the aspect ratio and then convert the image into different size variants.

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

}

Can somebody help in debugging the issue? I am kind of stuck on this for the past 3 hours.My AWS Lambda is in Tokyo Region.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the exact same error message occur on a process that had been running flawlessly for the last 5 weeks. After speaking with AWS support today, I was informed that native library support for Imagemagick was removed from AWS Lambda due to the vulnerability that was found recently documented here https://imagetragick.com/.

I was told I would have to rebuild my Lambda function and bundle in my own version of the native library - https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/

The support representative confirmed that there had not been a public announcement of this change.

TLDR: If you had been using an AWS Lambda function that was dependent on the bundled in version of Imagemagick, as of 05/04/2016, it is now broken and probably will not work until you redeploy with your own built and maintained version of the library. May the fourth be with you...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...