AWS Lambda 无法与 gm 模块一起使用 [英] AWS Lambda not working along with the gm module

查看:35
本文介绍了AWS Lambda 无法与 gm 模块一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AWS Lambdas3 存储桶 使用节点 js 将图像转换为不同大小的变体放入 s3 存储桶.

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.

它一直工作到昨天.今天,当我使用相同的 lambda 函数时,出现以下错误:

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)"
    ]
}

我无法理解为什么会出现这种现象.下面我的 lambda 函数的所有给定函数都在 async 瀑布 中,首先计算纵横比,然后转换图像转换为不同大小的变体.

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

}

有人可以帮忙调试问题吗?在过去的 3 个小时里,我有点坚持这个.我的 AWS Lambda 在东京地区.

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.

推荐答案

我在过去 5 周一直完美运行的进程中出现完全相同的错误消息.在今天与 AWS 支持人员交谈后,我获悉 AWS Lambda 已从 AWS Lambda 中删除了对 Imagemagick 的本机库支持,原因是最近在此处记录的漏洞 https://imagetragick.com/.

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/.

有人告诉我,我必须在我自己的本机库版本中重建我的 Lambda 函数和包 - https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/

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:如果您一直在使用依赖于捆绑的 Imagemagick 版本的 AWS Lambda 函数,截至 2016 年 5 月 4 日,它现在已损坏并且可能无法使用,直到您重新部署您自己构建的和库的维护版本.愿第四个与你同在...

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...

这篇关于AWS Lambda 无法与 gm 模块一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆