Closed fergiemcdowall closed 6 years ago
Does lambda preserve the disk state between invocation? I would imagine Amazon rotates the location of the functions pretty heavily in the background so they're probably 'stateless'
For my use case it is fine if the instances are ephemeral.
I guess another way to formulate the question is: is there a standard way compile and distribute prebuilt binaries for node modules so that you can deploy bundles without npm installing?
http://apex.run/#function-hooks might be helpful
leveldown is installed via prebuilt already, so an npm install on aws should just fetch those
I guess another way to formulate the question is: is there a standard way compile and distribute prebuilt binaries for node modules so that you can deploy bundles without npm installing?
We're looking into prebuildify
(#482), which would include all prebuilts in the npm package, and therefore in the AWS deployment package.
Short of that, there is no standard way.
@fergiemcdowall you can compile the module inside a docker instance that matches the AWS Lambda runtime, then simply include that in your zip file that you upload to Lamda. That's how I've solved native dependencies in scandium.
@LinusU nice! I will give it a try.
@fergiemcdowall here is the docker file, in JS though 😆, but should be easy to see what it does.
https://github.com/LinusU/scandium/blob/master/lib/dockerfile.js
FROM amazonlinux:2017.03
Nice one! Didn't know they had docker images :)
Yeah, it's nice! It's also pinned at 2017.03
since the Lambda documentation says that that is the version that they are running at the moment.
Has anybody attempted to install leveldown on AWS Lambda? If so how did it go? What is the best strategy for installing the binary?