Example of using AWS Lambda with node-canvas. node-canvas
has a dependency on Cairo which is a native library with other native library dependencies which aren't currently available on the current AWS Lambda AMI (2015.09).
An AWS blog post describes the static compilation process (source):
You’ll need to either ensure that the libraries and their transitive dependencies are statically compiled or use rpath-style linking; we’ll do it the static way in this post, and demonstrate use of rpath in a subsequent post. (Note that many, but not all, libraries can be statically linked this way.)
However, to get this working for node-canvas I used dynamic linking with rpath
. I more or less followed the process outlined by mankins on this this node-canvas GitHub issue
src contains the compiled shared object files and index.js which contains the the lambda function (index.handler
).
dist is just the contents of src compressed into a zip file which should be ready to upload to AWS Lambda.