AWS Lambda not working along with the gm module

前端 未结 5 1266
刺人心
刺人心 2020-12-19 03:23

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 yesterd

5条回答
  •  遥遥无期
    2020-12-19 04:14

    It seems like your Lambda function has no access to your S3 bucket. Make sure that your function has an according IAM policy applied, e.g.:

    {
        "Version": "2012-10-17",
        "Statement": [{
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        }]
    }
    

    Although your problem has nothing to do with graphicsmagick, please note that AWS Lambda only comes with imagemagick installed. So unless you provide the graphicsmagick executables yourself make sure to use the imagemagic sub class:

    var gm = require("gm").subClass({ imageMagick: true });
    

提交回复
热议问题