Skip to content

Brikl/lambda-layer-canvas-fabric-arm64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lambda-layer-canvas-fabric-arm64

AWS Lambda Layer with node-canvas and Fabric included for ARM64 runtime

Do It by Yourself

Oh! You want to make your own layer with different version!? Don't worry we got you covered

Create an EC2 instance with Amazon Linux 2, you cannot get your node-canvas running if build environment is different from lambda (tl;dr mismatch glibc version)

Future note: It's possible that you come from the future and Amazon Linux 2 is no longer active runtime for Lambda. Check your current lambda operating system at AWS Docs, if it is ping me please and i will try to update docs later

AMI configuration

Then, install required dependencies for creating lambda layer by calling a script

./initialize.sh

If everything goes well, then you're ready to build a layer! Specifying your preferred canvas, and fabric version in build.sh then execute it

./build.sh

As a final result, you should have layer.zip at dist/ directory. Upload it to Lambda layer, and you should be ready to go.

Using them

Just add layer to Lambda function, and you should be able to use them normally

import canvas from 'canvas'
import fabric from 'fabric'

// code below

Troubleshooting

1. Some dependencies are not exist while building canvas

Check compiling section of node-canvas repository, try to check that is there some package were addded and initialize command does not have

node-canvas Repo

2. It broke my function!

Please make sure that

  • You're running lambda function as arm64
  • Your created EC2 instance is an arm64 instance
  • Node version for your Lambda runtime, and EC2 instance are the same major version

3. I want to build with different Node version

Check this line of initizlization. You can change way to install Node here. Just make sure that you're installing arm64 version of Node, not amd64