a lambda deployment package for generating thumbnails
in the directory has index.js
npm init -y
npm install async gm pdf2png --save
- make zip including
node_modules
andindex.js
named likeCreateThumbnail.zip
go to AWS Console IAM
from the official tutorial
- Follow the steps in Creating a Role to Delegate Permissions to an AWS Service in the IAM User Guide to create an IAM role (execution role). As you follow the steps to create a role, note the following:
- In Role Name, use a name that is unique within your AWS account (for example, lambda-s3-execution-role).
- In Select Role Type, choose AWS Service Roles, and then choose AWS Lambda. This grants the AWS Lambda service permissions to assume the role.
- In Attach Policy, choose AWSLambdaExecute.
- Write down the role ARN. You will need it in the next step when you create your Lambda function.
go to AWS Console lambda
create a lambda function
next
- select s3 as a trigger
- select a bucket like
bucketname-assets-test
- event type :
Object Created (All)
next
- create target bucket
- create a bucket like
bucketname-thumbnails
- configure
- name such as
CreateThumbnail
- Runtime:
Node.js 4.3
- Lambda function:
Upload a .ZIP file
- select the file (
CreateThumbnail.zip
) - Lambda function handler and role:
Handler:
index.handler
Role:Choose an existing role
existing role: role likelambda-s3-exec-role
- Advanced settings: leave it as it is
next
create function
- set trigger enable
- upload a file in to the S3 bucket (like
bucketname-assets-test
) - you can check log at Cloud Watch
Hey, any plan to upgrade it to Runtime Node.js 8.10?