@beesley/push-function-zips
Zips up and uploads build artifacts for serverless functions
usage
cli
Typically this module would be used from the command line. The command line args are described here.
Argument | Description | Type | Required? |
---|
--help | Show help | [boolean] | |
--version | Show version number | [boolean] | |
--inputPath | The path to the lambda code and node_modules | [string] | [required] |
--include | An array of globs defining what to bundle | [array] | [required] |
--exclude | An array of globs defining what not to bundle | [array] | |
--rootDir | An optional path within the zip to save the files to | [string] | |
--regions | A list of regions to upload the assets in | [array] | [required] |
--s3Buckets | A list of buckets to upload to (same order as the regions please) | [array] | [required] |
--s3FunctionKey | The path/filename of the zip file in the bucket (you don't need to add the .zip extension, but remember to include a version string of some sort) | [string] | [required] |
--s3LayerKey | Tells the module to split out the node modules into a zip that you can create a lambda layer from | [string] | |
npx @beesley/push-function-zips --inputPath './' --include 'dist/**' --regions 'eu-central-1' --s3Buckets 'my-lambda-artefacts' --s3FunctionKey 'hello-function' --s3LayerKey 'hello-function-dependencies'
programmatic
It is possible to use this module programmatically if you so desire.
import { packageAndUpload } from '@beesley/push-function-zips';
await packageAndUpload({
inputPath: './',
include: ['dist/**'],
createLayer: true,
region: 'eu-central-1',
s3Bucket: 'my-lambda-artefacts',
s3FunctionKey: 'hello-function',
s3LayerKey: 'hello-function-dependencies',
});
API
Table of Contents
Options
src/package-and-upload.ts:15-70
Options to define an upload task
Type: {inputPath: string, include: Array<string>?, exclude: Array<string>?, createLayer: boolean?, rootDir: string?, region: string, s3Bucket: string, s3FunctionKey: string, s3LayerKey: string?}
Properties
inputPath
src/package-and-upload.ts:21-21
A pointer to where the files to upload are located
Type: string
include
src/package-and-upload.ts:27-27
An array of globs to include in the zip
Type: Array<string>
exclude
src/package-and-upload.ts:33-33
An array of globs to exclude from the zip
Type: Array<string>
createLayer
src/package-and-upload.ts:39-39
Whether or not to create a layer zip
Type: boolean
rootDir
src/package-and-upload.ts:45-45
A position within the zip to mount the files
Type: string
region
src/package-and-upload.ts:51-51
The AWS region to upload the assets to
Type: string
s3Bucket
src/package-and-upload.ts:57-57
The name of the S3 bucket to upload to
Type: string
s3FunctionKey
src/package-and-upload.ts:63-63
The key name to upload the function zip as
Type: string
s3LayerKey
src/package-and-upload.ts:69-69
The key name to upload the layer as
Type: string
packageAndUpload
src/package-and-upload.ts:271-287
Packages up an asset based on globs and uploads zips to s3
Parameters
arg
Options Configuration defining what to upload to where
Returns any {Promise}