- Notifications
You must be signed in to change notification settings - Fork8
A layer for AWS Lambda (nodejs) that allows you to use better-sqlite3 without having to compile the native module yourself. Also can be a template for any natively-compiled nodejs modules for AWS Lambda Layers.
License
seanfisher/better-sqlite3-lambda-layer
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Alayer for AWS Lambda that allows you to usebetter-sqlite3 without having to compile any native modules. Just include this layer and then your code can accessbetter-sqlite3 normally when running in AWS Lambda.
It also serves as a template and example for using any native-compiled module with a nodejs lambda.
When configuring your lambda, click on Layers and choose "Add a layer". Choose "Provide a layer version ARN" and use the following ARN (latest version -see all versions):
arn:aws:lambda:us-east-1:284387765956:layer:BetterSqlite3:9Then, in your code, simply require and use better-sqlite3 as you normally would:
const db = require('better-sqlite3')('myDatabase.db', {options});See theexample.
Clone this repo:
git clone git@github.com:seanfisher/better-sqlite3-lambda-layer.gitYou can use the build script to build the layer directory:
./build.shThen useserverless to deploy the layer and example function to your own account:
sls deployTo build and deploy in one step:
npm run deployIt should spit out the name of the ARN that you can use in your other lambdas.
If you want to use a lambda globally, you can run this command to grant access globally (replace $VERSION with the correct version):
aws lambda add-layer-version-permission --layer-name BetterSqlite3 --statement-id global-lambda-layer-access --version-number $VERSION --principal '*' --action lambda:GetLayerVersionThis repo should also work with other native modules - just build your application normally usingnpm install. You can even run your application locally; the build script takes your entirenode_modules folder, installs the production dependencies built using a lambda environment, and packages it up into the layer.
Since currently all the productionnode_modules are included in the layer, they are excluded from the serverless deployment package.
| node.js version | better-sqlite3 version | ARN |
|---|---|---|
| 12.x | 5.4.0 | arn:aws:lambda:us-east-1:284387765956:layer:BetterSqlite3:8 |
| 12.x | 6.0.1 | arn:aws:lambda:us-east-1:284387765956:layer:BetterSqlite3:9 |
About
A layer for AWS Lambda (nodejs) that allows you to use better-sqlite3 without having to compile the native module yourself. Also can be a template for any natively-compiled nodejs modules for AWS Lambda Layers.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.