A node-canvas (and chart.js) layer for AWS Lambda
Note: If you're not using Node.js version 12 then you'll need to recompile the layers. See the Build section below. Also, these layers include chart.js. If you don't want these modules included you can remove them from the Dockerfile (around line 19) and rebuild the layers.
- Clone the repository
- Log into AWS console and navigate to Lambda service
- Click Layers in the sidebar
- Click Create layer
- Give the layer a name, description and upload the
node12_canvas_layer.zip
- Click Create
- Follow the previous 3 steps and create a layer for
node12_canvas-lib64-layer.zip
- Click Functions in the sidebar
- Select your function in the function list
- Click Layers in the Designer panel
- In the Layers panel click Add a layer.
- Choose Select from list of runtime compatible layers, select the layer Name and Version and click Add.
Clone the repository and follow the steps below.
aws lambda publish-layer-version \
--layer-name "node12CanvasLib64" \
--zip-file "fileb://node12_canvas_lib64_layer.zip" \
--description "Node canvas lib 64"
aws lambda publish-layer-version \
--layer-name "node12Canvas" \
--zip-file "fileb://node12_canvas_layer.zip" \
--description "A Lambda Layer which includes node canvas, chart.js, chartjs-node-canvas, chartjs-plugin-datalabels"
The build script included in this repo will compile new layers and (optionally) uploaded them to AWS into your default region. Be sure to have Docker installed then run the follwing command:
./build.sh