aws Lambda Function for creating thumbnails of images uploaded to a s3 bucket
Uses sharp image processing module to resize images.
$ npm install
$ zip -r thumbnailer.zip index.js node_modules/ package.json package-lock.json
Create a folder named 'thumbnails' in the bucket where you will be uploading images. S3 bucket and the lambda function should be in the same region.
- Create a new Lambda from aws console
- Goto Function code of the newly created Lambda and upload the thumbnailer.zip file
- Create a new Role in IAM and attach AWSLambdaExecute policy
- Select this role as your Lambda's Execution role
- If the images are pretty large you can increase the timeout value in Lambda.
In you S3 bucket properties, add an event notification to notify Lambda whenever some file is uploaded to your bucket.