3

AWS lambda does not support installing linux binaries on the system, you would have to include the executables on your system. this would be easy for executables such as ffmpeg that already supply static executables.

How would this work for node binary addons that are compiled to using node-gyp? Would simply including the build/ directory from a linux environment work?

Has anyone figured this out yet?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Jonathan Ong
  • 19,927
  • 17
  • 79
  • 118

1 Answers1

1

In our case, it was node-dv module, which is built using node-gyp. The following steps make it work:

  1. Spawn new EC2 instance. Make sure it is based on exactly the same image as your AWS Lambda runtime. You can review Lambda env details here: http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html. In our case, it was Amazon Linux AMI called amzn-ami-hvm-2015.03.0.x86_64-gp2.

  2. Install nvm and use it to install the same version of Node.js as on the AWS Lambda. At the time of writing this, it was v0.10.36. You can refer to http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html again to find out.

  3. You will probably need to install git & g++ compiler on the EC2. You can do this running

    sudo yum install git gcc-c++
  4. Finally, clone your app to your new EC2 and install your app's dependecies:

    nvm use 0.10.36
    npm install --production
    
Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
xaralis
  • 4,634
  • 1
  • 23
  • 20
  • I don't understand which EC2 is which. I get that one sets up the system software on a EC2 instance. But how does the second one come into the picture? Lambda only supports certain environments. On what machine will the the new EC2 instance live? How does one clone the new EC2 instance into a Lambda environment? Does the npm install get done everytime it is called, I presume not? – Grant Rostig Aug 12 '17 at 03:08