node-lambda 0.19.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,19 +3,38 @@ name: Node CI
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
- test:
7
- name: Test on node ${{ matrix.node-version }} and ${{ matrix.os }}
8
- runs-on: ${{ matrix.os }}
6
+ ubuntu-test:
7
+ name: Test on node ${{ matrix.node-version }} and Ubuntu
8
+ runs-on: ubuntu-latest
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- node-version: [10.x, 12.x, 14.x]
13
- os: [ubuntu-latest, windows-latest, macos-latest]
12
+ node-version: [14.x, 16.x, 17.x]
14
13
  steps:
15
- - uses: actions/checkout@master
16
- - uses: actions/setup-node@master
14
+ - uses: actions/checkout@v2
15
+ - uses: actions/setup-node@v2
17
16
  with:
18
17
  node-version: ${{ matrix.node-version }}
18
+ cache: 'npm'
19
+ - run: npm i -g npm
20
+ - run: node -v
21
+ - run: npm -v
22
+ - run: npm ci
23
+ - run: npm test
24
+
25
+ mac-and-windows-test:
26
+ name: Test on node latest and ${{ matrix.os }}
27
+ runs-on: ${{ matrix.os }}
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ os: [windows-latest, macos-latest]
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ - uses: actions/setup-node@v2
35
+ with:
36
+ node-version: 16.x
37
+ cache: 'npm'
19
38
  - run: npm i -g npm
20
39
  - run: node -v
21
40
  - run: npm -v
package/.travis.yml CHANGED
@@ -4,6 +4,8 @@ node_js:
4
4
  - "lts/*"
5
5
  - "node"
6
6
 
7
+ install: npm i -g npm
8
+
7
9
  cache:
8
10
  directories:
9
11
  - node_modules
package/CHANGELOG.md CHANGED
@@ -425,3 +425,28 @@ This project adheres to [Semantic Versioning](http://semver.org/).
425
425
  ## [0.19.0] - 2021-03-30
426
426
  ### Features
427
427
  - feat: support `--no-optional` option in npm install [#557](https://github.com/motdotla/node-lambda/pull/557)
428
+
429
+ ## [0.19.1] - 2021-04-24
430
+ ### Bugfixes
431
+ - Fix errors caused by old proxy-agent [#564](https://github.com/motdotla/node-lambda/pull/564)
432
+
433
+ ## [0.20.0] - 2021-09-25
434
+ ### Features
435
+ - updated proxy-agent to 5.0.0 [#574](https://github.com/motdotla/node-lambda/pull/574)
436
+ - show suggestions after an error for an unknown command or option [#572](https://github.com/motdotla/node-lambda/pull/572)
437
+ - feat: drop nodejs10x from lambda runtime [#571](https://github.com/motdotla/node-lambda/pull/571)
438
+
439
+ ### Bugfixes
440
+ - fix(_uploadExisting): fix function update errors [#575](https://github.com/motdotla/node-lambda/pull/575)
441
+ - test: fix npm install test failing in some cases [#569](https://github.com/motdotla/node-lambda/pull/569)
442
+ - Clean the tmp dir during `_archivePrebuilt` to match `_buildAndArchive` behavior [#518](https://github.com/motdotla/node-lambda/pull/518)
443
+
444
+ ## [0.21.0] - 2021-11-10
445
+ ### Features
446
+ - feat: support for yarn [#581](https://github.com/motdotla/node-lambda/pull/581)
447
+
448
+ ## [0.22.0] - 2022-02-17
449
+ ### Features
450
+ - Support for Architectures parameter [#591](https://github.com/motdotla/node-lambda/pull/591)
451
+ ### Bugfixes
452
+ - fix: skip installing the package, when there is no `package.json` [#589](https://github.com/motdotla/node-lambda/pull/589)
package/README.md CHANGED
@@ -64,6 +64,7 @@ $ echo -e ".env\ndeploy.env\nevent.json\n.lambda" >> .gitignore
64
64
  ##### Deploy env variables
65
65
 
66
66
  ```
67
+ PACKAGE_MANAGER // (default: 'npm')
67
68
  AWS_ENVIRONMENT // (default: '')
68
69
  AWS_ENDPOINT // (default: '')
69
70
  CONFIG_FILE // (default: '')
@@ -80,6 +81,7 @@ AWS_ROLE_ARN || AWS_ROLE // (default: 'missing')
80
81
  AWS_MEMORY_SIZE // (default: 128)
81
82
  AWS_TIMEOUT // (default: 60)
82
83
  AWS_RUN_TIMEOUT // (default: 3)
84
+ AWS_ARCHITECTURE // (default: 'x86_64')
83
85
  AWS_DESCRIPTION // (default: package.json.description or '')
84
86
  AWS_RUNTIME // (default: 'nodejs14.x')
85
87
  AWS_PUBLISH // (default: false)
@@ -109,23 +111,21 @@ Runs your Amazon Lambda index.js file locally. Passes `event.json` data to the A
109
111
 
110
112
  ```
111
113
  $ node-lambda run --help
112
-
113
- Usage: run|execute [options]
114
+ Usage: node-lambda run|execute [options]
114
115
 
115
116
  Run your Amazon Lambda application locally
116
117
 
117
-
118
118
  Options:
119
- -h, --help output usage information
120
- -H, --handler [index.handler] Lambda Handler {index.handler}
121
- -j, --eventFile [event.json] Event JSON File
122
- -u, --runtime [nodejs14.x] Lambda Runtime
123
- -t, --timeout [3] Lambda Timeout
124
- -f, --configFile [] Path to file holding secret environment variables (e.g. "deploy.env")
125
- -x, --contextFile [context.json] Context JSON File
126
- -M, --enableRunMultipleEvents [true] Enable run multiple events
127
- -y, --proxy [] Proxy server
128
- --apiGateway Convert to API Gateway events
119
+ -H, --handler [AWS_HANDLER] Lambda Handler {index.handler} (default: "index.handler")
120
+ -j, --eventFile [EVENT_FILE] Event JSON File (default: "event.json")
121
+ -u, --runtime [AWS_RUNTIME] Lambda Runtime (default: "nodejs14.x")
122
+ -t, --timeout [AWS_RUN_TIMEOUT] Lambda Timeout (default: 3)
123
+ -f, --configFile [CONFIG_FILE] Path to file holding secret environment variables (e.g. "deploy.env") (default: "")
124
+ -x, --contextFile [CONTEXT_FILE] Context JSON File (default: "context.json")
125
+ -M, --enableRunMultipleEvents [ENABLE_RUN_MULTIPLE_EVENTS] Enable run multiple events (default: true)
126
+ -y, --proxy [PROXY] Proxy server (default: "")
127
+ --apiGateway Convert to API Gateway events (default: false)
128
+ -h, --help display help for command
129
129
  ```
130
130
 
131
131
  #### package
@@ -134,23 +134,26 @@ Bundles your application into a local zip file.
134
134
 
135
135
  ```
136
136
  $ node-lambda package --help
137
-
138
- Usage: package|zip [options]
137
+ Usage: node-lambda package|zip [options]
139
138
 
140
139
  Create zipped package for Amazon Lambda deployment
141
140
 
142
-
143
141
  Options:
144
- -h, --help output usage information
145
- -A, --packageDirectory [build] Local Package Directory
146
- -I, --dockerImage [] Docker image for npm install
147
- -n, --functionName [node-lambda] Lambda FunctionName
148
- -H, --handler [index.handler] Lambda Handler {index.handler}
149
- -e, --environment [development] Choose environment {dev, staging, production}
150
- -x, --excludeGlobs [event.json] Space-separated glob pattern(s) for additional exclude files (e.g. "event.json dotenv.sample")
151
- -D, --prebuiltDirectory [] Prebuilt directory
152
- -m, --keepNodeModules [false] Keep the current node_modules and skip the npm install step
153
- -v, --dockerVolumes [] Additional docker volumes to mount. Each volume definition has to be separated by a space (e.g. "$HOME/.gitconfig:/etc/gitconfig $HOME/.ssh:/root/.ssh"
142
+ --packageManager [PACKAGE_MANAGER] Package manager used to install dependencies (default: "npm", options: "npm", "yarn")
143
+ -A, --packageDirectory [PACKAGE_DIRECTORY] Local Package Directory
144
+ -I, --dockerImage [DOCKER_IMAGE] Docker image for npm ci (default: "")
145
+ -n, --functionName [AWS_FUNCTION_NAME] Lambda FunctionName (default: "node-lambda")
146
+ -H, --handler [AWS_HANDLER] Lambda Handler {index.handler} (default: "index.handler")
147
+ -e, --environment [AWS_ENVIRONMENT] Choose environment {dev, staging, production} (default: "")
148
+ -x, --excludeGlobs [EXCLUDE_GLOBS] Space-separated glob pattern(s) for additional exclude files (e.g.
149
+ "event.json dotenv.sample") (default: "")
150
+ -D, --prebuiltDirectory [PREBUILT_DIRECTORY] Prebuilt directory (default: "")
151
+ -m, --keepNodeModules [KEEP_NODE_MODULES] Keep the current node_modules directory. (default: false)
152
+ -v, --dockerVolumes [DOCKER_VOLUMES] Additional docker volumes to mount. Each volume definition has to be
153
+ separated by a space (e.g. "$HOME/.gitconfig:/etc/gitconfig
154
+ $HOME/.ssh:/root/.ssh") (default: "")
155
+ --no-optionalDependencies Run `npm install` with `--no-optional`
156
+ -h, --help display help for command
154
157
  ```
155
158
 
156
159
  #### deploy
@@ -159,50 +162,51 @@ Bundles and deploys your application up to Amazon Lambda.
159
162
 
160
163
  ```
161
164
  $ node-lambda deploy --help
162
-
163
- Usage: deploy [options]
165
+ Usage: node-lambda deploy [options]
164
166
 
165
167
  Deploy your application to Amazon Lambda
166
168
 
167
-
168
169
  Options:
169
- -h, --help output usage information
170
- -e, --environment [development] Choose environment {dev, staging, production}
171
- -E, --endpoint [AWS_ENDPOINT] Choose endpoint (e.g. localstack, "http://127.0.0.1:4574") (default: "")
172
- -a, --accessKey [your_key] AWS Access Key
173
- -s, --secretKey [your_secret] AWS Secret Key
174
- -P, --profile [] AWS Profile
175
- -k, --sessionToken [] AWS Session Token
176
- -r, --region [us-east-1] AWS Region
177
- -n, --functionName [node-lambda] Lambda FunctionName
178
- -H, --handler [index.handler] Lambda Handler {index.handler}
179
- -o, --role [your_amazon_role] Amazon Role ARN
180
- -m, --memorySize [128] Lambda Memory Size
181
- -t, --timeout [3] Lambda Timeout
182
- -d, --description [missing] Lambda Description
183
- -u, --runtime [nodejs14.x] Lambda Runtime
184
- -p, --publish [false] Lambda Publish
185
- -L, --lambdaVersion [] Lambda Function Version
186
- -b, --vpcSubnets [] Lambda Function VPC Subnet IDs (comma delimited)
187
- -g, --vpcSecurityGroups [] Lambda VPC Security Group IDs (comma delimited)
188
- -K, --kmsKeyArn [] Lambda KMS Key ARN
189
- -Q, --deadLetterConfigTargetArn [] Lambda DLQ resource
190
- -c, --tracingConfig [] Lambda tracing settings
191
- -l, --layers [] Lambda Layers settings (e.g. "ARN1,ARN2[,..])" (default: "")
192
- -R, --retentionInDays [] CloudWatchLogs retentionInDays settings
193
- -G, --sourceDirectory [] Path to lambda source Directory (e.g. "./some-lambda")
194
- -I, --dockerImage [] Docker image for npm install
195
- -f, --configFile [] Path to file holding secret environment variables (e.g. "deploy.env")
196
- -S, --eventSourceFile [] Path to file holding event source mapping variables (e.g. "event_sources.json")
197
- -x, --excludeGlobs [event.json] Space-separated glob pattern(s) for additional exclude files (e.g. "event.json dotenv.sample")
198
- -D, --prebuiltDirectory [] Prebuilt directory
199
- -T, --deployTimeout [120000] Deploy Timeout
200
- -z, --deployZipfile [] Deploy zipfile
201
- -B, --deployUseS3 [] Use S3 to deploy.
202
- -i, --imageUri [] URI of a container image in the Amazon ECR registry. (default: "")
203
- -y, --proxy [] Proxy server
204
- -A, --tags [] Tags as key value pairs (e.g. "tagname1=tagvalue1,tagname2=tagvalue2") (default: "")
205
- --silent Silent or quiet mode (default: false)
170
+ --packageManager [PACKAGE_MANAGER] Package manager used to install dependencies (default: "npm", options: "npm", "yarn")
171
+ -e, --environment [AWS_ENVIRONMENT] Choose environment {dev, staging, production} (default: "")
172
+ -E, --endpoint [AWS_ENDPOINT] Choose endpoint (e.g. localstack, "http://127.0.0.1:4574") (default: "")
173
+ -a, --accessKey [AWS_ACCESS_KEY_ID] AWS Access Key
174
+ -s, --secretKey [AWS_SECRET_ACCESS_KEY] AWS Secret Key
175
+ -P, --profile [AWS_PROFILE] AWS Profile (default: "")
176
+ -k, --sessionToken [AWS_SESSION_TOKEN] AWS Session Token (default: "")
177
+ -r, --region [AWS_REGION] AWS Region (default: "us-east-1,us-west-2,eu-west-1")
178
+ -n, --functionName [AWS_FUNCTION_NAME] Lambda FunctionName (default: "node-lambda")
179
+ -H, --handler [AWS_HANDLER] Lambda Handler {index.handler} (default: "index.handler")
180
+ -o, --role [AWS_ROLE] Amazon Role ARN (default: "missing")
181
+ -m, --memorySize [AWS_MEMORY_SIZE] Lambda Memory Size (default: 128)
182
+ -t, --timeout [AWS_TIMEOUT] Lambda Timeout (default: 60)
183
+ --architecture [AWS_ARCHITECTURE] The instruction set architecture that the function supports. (x86_64|arm64) (default: "x86_64")
184
+ -d, --description [AWS_DESCRIPTION] Lambda Description (default: "Command line tool for locally running and remotely deploying your node.js applications to Amazon Lambda.")
185
+ -u, --runtime [AWS_RUNTIME] Lambda Runtime (default: "nodejs14.x")
186
+ -p, --publish [AWS_PUBLISH] Lambda Publish (default: false)
187
+ -L, --lambdaVersion [AWS_FUNCTION_VERSION] Lambda Function Version (default: "")
188
+ -b, --vpcSubnets [AWS_VPC_SUBNETS] Lambda Function VPC Subnet IDs (comma delimited) (default: "")
189
+ -g, --vpcSecurityGroups [AWS_VPC_SECURITY_GROUPS] Lambda VPC Security Group IDs (comma delimited) (default: "")
190
+ -K, --kmsKeyArn [AWS_KMS_KEY_ARN] Lambda KMS Key ARN (default: "")
191
+ -Q, --deadLetterConfigTargetArn [AWS_DLQ_TARGET_ARN] Lambda DLQ resource
192
+ -c, --tracingConfig [AWS_TRACING_CONFIG] Lambda tracing settings (default: "")
193
+ -l, --layers [AWS_LAYERS] Lambda Layers settings (e.g. "ARN1,ARN2[,..])" (default: "")
194
+ -R, --retentionInDays [AWS_LOGS_RETENTION_IN_DAYS] CloudWatchLogs retentionInDays settings (default: "")
195
+ -G, --sourceDirectory [SRC_DIRECTORY] Path to lambda source Directory (e.g. "./some-lambda") (default: "")
196
+ -I, --dockerImage [DOCKER_IMAGE] Docker image for npm ci (default: "")
197
+ -f, --configFile [CONFIG_FILE] Path to file holding secret environment variables (e.g. "deploy.env") (default: "")
198
+ -S, --eventSourceFile [EVENT_SOURCE_FILE] Path to file holding event source mapping variables (e.g. "event_sources.json") (default: "")
199
+ -x, --excludeGlobs [EXCLUDE_GLOBS] Space-separated glob pattern(s) for additional exclude files (e.g. "event.json dotenv.sample") (default: "")
200
+ -D, --prebuiltDirectory [PREBUILT_DIRECTORY] Prebuilt directory (default: "")
201
+ -T, --deployTimeout [DEPLOY_TIMEOUT] Deploy Timeout (default: 120000)
202
+ -z, --deployZipfile [DEPLOY_ZIPFILE] Deploy zipfile (default: "")
203
+ -B, --deployUseS3 [DEPLOY_USE_S3] Use S3 to deploy. (default: false)
204
+ -i, --imageUri [IMAGE_URI] URI of a container image in the Amazon ECR registry. (default: "")
205
+ -y, --proxy [PROXY] Proxy server (default: "")
206
+ -A, --tags [AWS_TAGS] Tags as key value pairs (e.g. "tagname1=tagvalue1,tagname2=tagvalue2)" (default: "")
207
+ --silent Silent or quiet mode (default: false)
208
+ --no-optionalDependencies Run `npm install` with `--no-optional`
209
+ -h, --help display help for command
206
210
  ```
207
211
 
208
212
  If you are deploying to a custom endpoint you may also need to pass in an access key/secret. For localstack these can be anything, but cannot be blank:
@@ -217,7 +221,32 @@ AWS Lambda will let you set environment variables for your function. Use the sam
217
221
 
218
222
  ## Node.js Runtime Configuration
219
223
 
220
- AWS Lambda now supports Node.js14, Node.js 12 and Node.js 10. Please also check the [Building Lambda functions with Node.js](https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html) page.
224
+ AWS Lambda now supports Node.js14 and Node.js 12. Please also check the [Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) page.
225
+
226
+ ## Use S3 to deploy
227
+
228
+ Use the command line argument `--deployUseS3` or `-B`. (This option is true/false.)
229
+ Example: `% node-lambda deploy -B`
230
+
231
+ You can also set the environment variable `DEPLOY_USE_S3`.
232
+ Example: `DEPLOY_USE_S3=true`
233
+
234
+ Use the environment variable to set the bucket name or S3 key prefix.
235
+ The environment variable name is different for each region. Please set it to the environment variable you want to deploy.
236
+ It can be set in `.env`.
237
+
238
+ Example:
239
+
240
+ ```sh
241
+ # S3_<region>_BUCKET
242
+ S3_US_WEST_1_BUCKET=test_aaa
243
+
244
+ # S3_<region>_PREFIX
245
+ S3_US_WEST_1_PREFIX=bbb
246
+ ```
247
+
248
+ In this case, the S3 key:
249
+ `test_aaa/bbb/deploy-package-${FunctionName}.zip`
221
250
 
222
251
  ## To deploy a container image to Lambda
223
252
 
package/bin/node-lambda CHANGED
@@ -3,6 +3,7 @@
3
3
  'use strict'
4
4
 
5
5
  require('dotenv').config()
6
+ const process = require('process')
6
7
  const path = require('path')
7
8
 
8
9
  const lambda = require(path.join(__dirname, '..', 'lib', 'main.js'))
@@ -11,6 +12,7 @@ const fs = require('fs')
11
12
  const packageJson = fs.existsSync(path.join(process.cwd(), 'package.json')) ? require(path.join(process.cwd(), 'package.json')) : {}
12
13
  const packageJsonName = packageJson.name || 'UnnamedFunction'
13
14
 
15
+ const PACKAGE_MANAGER = process.env.PACKAGE_MANAGER || 'npm'
14
16
  const AWS_ENVIRONMENT = process.env.AWS_ENVIRONMENT || ''
15
17
  const AWS_ENDPOINT = process.env.AWS_ENDPOINT || ''
16
18
  const CONFIG_FILE = process.env.CONFIG_FILE || ''
@@ -27,6 +29,7 @@ const AWS_ROLE = process.env.AWS_ROLE_ARN || process.env.AWS_ROLE || 'missing'
27
29
  const AWS_MEMORY_SIZE = process.env.AWS_MEMORY_SIZE || 128
28
30
  const AWS_TIMEOUT = process.env.AWS_TIMEOUT || 60
29
31
  const AWS_RUN_TIMEOUT = process.env.AWS_RUN_TIMEOUT || 3
32
+ const AWS_ARCHITECTURE = process.env.AWS_ARCHITECTURE || 'x86_64'
30
33
  const AWS_DESCRIPTION = process.env.AWS_DESCRIPTION || packageJson.description || ''
31
34
  const AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs14.x'
32
35
  const AWS_PUBLISH = process.env.AWS_PUBLISH || false
@@ -64,6 +67,7 @@ const IMAGE_URI = process.env.IMAGE_URI || ''
64
67
  program
65
68
  .command('deploy')
66
69
  .description('Deploy your application to Amazon Lambda')
70
+ .option('--packageManager [PACKAGE_MANAGER]', 'Package manager used to install dependencies', PACKAGE_MANAGER)
67
71
  .option('-e, --environment [AWS_ENVIRONMENT]', 'Choose environment {dev, staging, production}',
68
72
  AWS_ENVIRONMENT)
69
73
  .option('-E, --endpoint [AWS_ENDPOINT]', 'Choose endpoint (e.g. localstack, "http://127.0.0.1:4574")',
@@ -78,6 +82,7 @@ program
78
82
  .option('-o, --role [AWS_ROLE]', 'Amazon Role ARN', AWS_ROLE)
79
83
  .option('-m, --memorySize [AWS_MEMORY_SIZE]', 'Lambda Memory Size', AWS_MEMORY_SIZE)
80
84
  .option('-t, --timeout [AWS_TIMEOUT]', 'Lambda Timeout', AWS_TIMEOUT)
85
+ .option('--architecture [AWS_ARCHITECTURE]', 'The instruction set architecture that the function supports. (x86_64|arm64)', AWS_ARCHITECTURE)
81
86
  .option('-d, --description [AWS_DESCRIPTION]', 'Lambda Description', AWS_DESCRIPTION)
82
87
  .option('-u, --runtime [AWS_RUNTIME]', 'Lambda Runtime', AWS_RUNTIME)
83
88
  .option('-p, --publish [AWS_PUBLISH]', 'Lambda Publish', AWS_PUBLISH)
@@ -121,6 +126,7 @@ program
121
126
  .command('package')
122
127
  .alias('zip')
123
128
  .description('Create zipped package for Amazon Lambda deployment')
129
+ .option('--packageManager [PACKAGE_MANAGER]', 'Package manager used to install dependencies', PACKAGE_MANAGER)
124
130
  .option('-A, --packageDirectory [PACKAGE_DIRECTORY]', 'Local Package Directory', PACKAGE_DIRECTORY)
125
131
  .option('-I, --dockerImage [DOCKER_IMAGE]', 'Docker image for npm ci', DOCKER_IMAGE)
126
132
  .option('-n, --functionName [AWS_FUNCTION_NAME]', 'Lambda FunctionName', AWS_FUNCTION_NAME)
@@ -159,12 +165,6 @@ program
159
165
  .option('-x, --contextFile [CONTEXT_FILE]', 'Context JSON File', CONTEXT_FILE)
160
166
  .action((prg) => lambda.setup(prg))
161
167
 
162
- program.on('command:*', (cmd) => {
163
- console.log(`Unknown command ${cmd}`)
164
- console.log()
165
- program.help()
166
- })
167
-
168
168
  program
169
169
  .version(lambda.version)
170
170
  .parse(process.argv)