Example of a Image resizer using AWS lambda and S3
This is a node implementation of an image resizer while a I took the AWS Lambda and the Serverless Framework course.
This is an interesting exercise since it uses a 'native' library for image resizing: Sharp
+--------+ +----------+ +--------+
| | | | | |
| S3 | +--------------> | Lambda | +-------------> | S3 |
| | trigger | | push | |
+--------+ +----------+ +--------+
new image creates a new thumbnail
uploaded thumbnail created
The deploy is done using the Serverless Framework .
sls deploy -v
You need Serverless to be installed and configured. Additionally you may need to install some plugins for size reduction,
# npm install serverless-plugin-include-dependencies serverless-plugin-common-excludes --save-dev
yarn add --dev serverless-plugin-include-dependencies serverless-plugin-common-excludes
Since Sharp library has native extensions, you need Linux binaries when deploying (AWS runs on linux). If your local machine runs Linux your are fine. Otherwise read https://sharp.pixelplumbing.com/install#aws-lambda
based on https://github.com/serverless/examples/tree/master/aws-node-dynamic-image-resize but simpler.