Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

NotificationsYou must be signed in to change notification settings

seanfisher/better-sqlite3-lambda-layer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Usage

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:9

Then, in your code, simply require and use better-sqlite3 as you normally would:

const db = require('better-sqlite3')('myDatabase.db', {options});

See theexample.

Hosting This In Your Own Account

Clone this repo:

git clone git@github.com:seanfisher/better-sqlite3-lambda-layer.git

You can use the build script to build the layer directory:

./build.sh

Then useserverless to deploy the layer and example function to your own account:

sls deploy

To build and deploy in one step:

npm run deploy

It 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:GetLayerVersion

Customization

This 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.

Version ARNs

node.js versionbetter-sqlite3 versionARN
12.x5.4.0arn:aws:lambda:us-east-1:284387765956:layer:BetterSqlite3:8
12.x6.0.1arn: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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp