node-lambda 1.2.1 → 2.0.0-alpha.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.
- package/.github/workflows/codeql-analysis.yml +3 -3
- package/.github/workflows/workflow.yml +2 -2
- package/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/bin/node-lambda +1 -1
- package/index_mjs.mjs +9 -0
- package/lib/.env.example +2 -1
- package/lib/aws.js +41 -38
- package/lib/cloudwatch_logs.js +22 -32
- package/lib/main.js +155 -170
- package/lib/s3_deploy.js +18 -24
- package/lib/s3_events.js +16 -27
- package/lib/schedule_events.js +21 -35
- package/package.json +12 -9
- package/tea.yaml +6 -0
- package/test/cloudwatch_logs.js +17 -13
- package/test/main.js +93 -61
- package/test/node-lambda.js +69 -10
- package/test/s3_deploy.js +15 -15
- package/test/s3_events.js +15 -17
- package/test/schedule_events.js +15 -17
|
@@ -29,7 +29,7 @@ jobs:
|
|
|
29
29
|
|
|
30
30
|
# Initializes the CodeQL tools for scanning.
|
|
31
31
|
- name: Initialize CodeQL
|
|
32
|
-
uses: github/codeql-action/init@
|
|
32
|
+
uses: github/codeql-action/init@v3
|
|
33
33
|
with:
|
|
34
34
|
languages: ${{ matrix.language }}
|
|
35
35
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
@@ -40,7 +40,7 @@ jobs:
|
|
|
40
40
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
41
41
|
# If this step fails, then you should remove it and run the build manually (see below)
|
|
42
42
|
- name: Autobuild
|
|
43
|
-
uses: github/codeql-action/autobuild@
|
|
43
|
+
uses: github/codeql-action/autobuild@v3
|
|
44
44
|
|
|
45
45
|
# ℹ️ Command-line programs to run using the OS shell.
|
|
46
46
|
# 📚 https://git.io/JvXDl
|
|
@@ -54,4 +54,4 @@ jobs:
|
|
|
54
54
|
# make release
|
|
55
55
|
|
|
56
56
|
- name: Perform CodeQL Analysis
|
|
57
|
-
uses: github/codeql-action/analyze@
|
|
57
|
+
uses: github/codeql-action/analyze@v3
|
|
@@ -9,7 +9,7 @@ jobs:
|
|
|
9
9
|
strategy:
|
|
10
10
|
fail-fast: false
|
|
11
11
|
matrix:
|
|
12
|
-
node-version: [
|
|
12
|
+
node-version: [20.x, 22.x]
|
|
13
13
|
steps:
|
|
14
14
|
- uses: actions/checkout@v4
|
|
15
15
|
- uses: actions/setup-node@v4
|
|
@@ -32,7 +32,7 @@ jobs:
|
|
|
32
32
|
- uses: actions/checkout@v4
|
|
33
33
|
- uses: actions/setup-node@v4
|
|
34
34
|
with:
|
|
35
|
-
node-version:
|
|
35
|
+
node-version: 22.x
|
|
36
36
|
cache: 'npm'
|
|
37
37
|
- run: node -v
|
|
38
38
|
- run: npm -v
|
package/CHANGELOG.md
CHANGED
|
@@ -480,3 +480,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
480
480
|
- Improve testing
|
|
481
481
|
- Update dependencies
|
|
482
482
|
- Update README
|
|
483
|
+
|
|
484
|
+
## [1.3.0] - 2024-01-04
|
|
485
|
+
### Features
|
|
486
|
+
- Support .mjs [#701](https://github.com/motdotla/node-lambda/pull/701)
|
|
487
|
+
- Update lambda runtime list [#702](https://github.com/motdotla/node-lambda/pull/702)
|
|
488
|
+
|
|
489
|
+
### Minor changes
|
|
490
|
+
- Update dependencies
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
If you found this useful, consider also checking out [
|
|
1
|
+
> If you found this useful, consider also checking out [dotenvx](https://github.com/dotenvx/dotenvx). Thank you! 😇
|
|
2
2
|
|
|
3
3
|
# node-lambda
|
|
4
4
|
|
|
@@ -230,7 +230,7 @@ AWS Lambda will let you set environment variables for your function. Use the sam
|
|
|
230
230
|
|
|
231
231
|
## Node.js Runtime Configuration
|
|
232
232
|
|
|
233
|
-
AWS Lambda now supports Node.js
|
|
233
|
+
AWS Lambda now supports Node.js 20, Node.js 18 and Node.js 16. Please also check the [Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) page.
|
|
234
234
|
|
|
235
235
|
## Use S3 to deploy
|
|
236
236
|
|
package/bin/node-lambda
CHANGED
package/index_mjs.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// For development/testing purposes
|
|
2
|
+
export const handler = (event, context, callback) => {
|
|
3
|
+
console.log('Running index.handler (mjs)')
|
|
4
|
+
console.log('==================================')
|
|
5
|
+
console.log('event', event)
|
|
6
|
+
console.log('==================================')
|
|
7
|
+
console.log('Stopping index.handler (mjs)')
|
|
8
|
+
callback(null)
|
|
9
|
+
}
|
package/lib/.env.example
CHANGED
|
@@ -10,10 +10,11 @@ AWS_HANDLER=index.handler
|
|
|
10
10
|
AWS_MEMORY_SIZE=128
|
|
11
11
|
AWS_TIMEOUT=3
|
|
12
12
|
AWS_DESCRIPTION=
|
|
13
|
-
AWS_RUNTIME=
|
|
13
|
+
AWS_RUNTIME=nodejs20.x
|
|
14
14
|
AWS_VPC_SUBNETS=
|
|
15
15
|
AWS_VPC_SECURITY_GROUPS=
|
|
16
16
|
AWS_TRACING_CONFIG=
|
|
17
17
|
AWS_LOGS_RETENTION_IN_DAYS=
|
|
18
18
|
EXCLUDE_GLOBS="event.json build/"
|
|
19
|
+
CONFIG_FILE="deploy.env"
|
|
19
20
|
PACKAGE_DIRECTORY=build
|
package/lib/aws.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
// TODO:
|
|
2
|
+
// Support these option settings in SDK v3
|
|
3
|
+
//
|
|
4
|
+
// 'use strict'
|
|
5
|
+
//
|
|
6
|
+
// const aws = require('aws-sdk')
|
|
7
|
+
// const proxy = require('proxy-agent')
|
|
8
|
+
//
|
|
9
|
+
// module.exports = {
|
|
10
|
+
// sdk: aws,
|
|
11
|
+
// updateConfig (config, region) {
|
|
12
|
+
// const awsSecurity = { region }
|
|
13
|
+
//
|
|
14
|
+
// if (config.profile) {
|
|
15
|
+
// aws.config.credentials = new aws.SharedIniFileCredentials({
|
|
16
|
+
// profile: config.profile
|
|
17
|
+
// })
|
|
18
|
+
// } else {
|
|
19
|
+
// awsSecurity.accessKeyId = config.accessKey
|
|
20
|
+
// awsSecurity.secretAccessKey = config.secretKey
|
|
21
|
+
// }
|
|
22
|
+
//
|
|
23
|
+
// if (config.sessionToken) {
|
|
24
|
+
// awsSecurity.sessionToken = config.sessionToken
|
|
25
|
+
// }
|
|
26
|
+
//
|
|
27
|
+
// if (config.deployTimeout) {
|
|
28
|
+
// aws.config.httpOptions.timeout = parseInt(config.deployTimeout)
|
|
29
|
+
// }
|
|
30
|
+
//
|
|
31
|
+
// if (config.proxy) {
|
|
32
|
+
// aws.config.httpOptions.agent = proxy(config.proxy)
|
|
33
|
+
// }
|
|
34
|
+
//
|
|
35
|
+
// if (config.endpoint) {
|
|
36
|
+
// aws.config.endpoint = config.endpoint
|
|
37
|
+
// }
|
|
38
|
+
//
|
|
39
|
+
// aws.config.update(awsSecurity)
|
|
40
|
+
// }
|
|
41
|
+
// }
|
package/lib/cloudwatch_logs.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const {
|
|
4
|
+
CloudWatchLogsClient,
|
|
5
|
+
CreateLogGroupCommand,
|
|
6
|
+
PutRetentionPolicyCommand
|
|
7
|
+
} = require('@aws-sdk/client-cloudwatch-logs')
|
|
8
|
+
|
|
3
9
|
class CloudWatchLogs {
|
|
4
|
-
constructor (
|
|
5
|
-
|
|
6
|
-
this.lambda = new aws.Lambda({
|
|
7
|
-
region,
|
|
8
|
-
apiVersion: '2015-03-31'
|
|
9
|
-
})
|
|
10
|
-
this.cloudwatchlogs = new aws.CloudWatchLogs({
|
|
11
|
-
apiVersion: '2014-03-28'
|
|
12
|
-
})
|
|
10
|
+
constructor (config) {
|
|
11
|
+
this.client = new CloudWatchLogsClient(config)
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
_logGroupName (params) {
|
|
@@ -17,33 +16,24 @@ class CloudWatchLogs {
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
_createLogGroup (params) {
|
|
20
|
-
|
|
21
|
-
this.
|
|
19
|
+
try {
|
|
20
|
+
return this.client.send(new CreateLogGroupCommand({
|
|
22
21
|
logGroupName: this._logGroupName(params)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
resolve(data)
|
|
33
|
-
})
|
|
34
|
-
})
|
|
22
|
+
}))
|
|
23
|
+
} catch (err) {
|
|
24
|
+
if (err.code === 'ResourceAlreadyExistsException') {
|
|
25
|
+
// If it exists it will result in an error but there is no problem.
|
|
26
|
+
return {}
|
|
27
|
+
}
|
|
28
|
+
throw err
|
|
29
|
+
}
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
_putRetentionPolicy (params) {
|
|
38
|
-
return new
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, (err, data) => {
|
|
43
|
-
if (err) return reject(err)
|
|
44
|
-
resolve(data)
|
|
45
|
-
})
|
|
46
|
-
})
|
|
33
|
+
return this.client.send(new PutRetentionPolicyCommand({
|
|
34
|
+
logGroupName: this._logGroupName(params),
|
|
35
|
+
retentionInDays: params.retentionInDays
|
|
36
|
+
}))
|
|
47
37
|
}
|
|
48
38
|
|
|
49
39
|
setLogsRetentionPolicy (params) {
|