Skip to content

Commit 76baf58

Browse files

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

bin/node-lambda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const AWS_FUNCTION_VERSION = process.env.AWS_FUNCTION_VERSION || ''
3737
const AWS_VPC_SUBNETS = process.env.AWS_VPC_SUBNETS || ''
3838
const AWS_VPC_SECURITY_GROUPS = process.env.AWS_VPC_SECURITY_GROUPS || ''
3939
const AWS_TRACING_CONFIG = process.env.AWS_TRACING_CONFIG || ''
40+
const AWS_LAYERS = process.env.AWS_LAYERS || ''
4041
const AWS_LOGS_RETENTION_IN_DAYS = process.env.AWS_LOGS_RETENTION_IN_DAYS || ''
4142
const EVENT_FILE = process.env.EVENT_FILE || 'event.json'
4243
const PACKAGE_DIRECTORY = process.env.PACKAGE_DIRECTORY
@@ -90,6 +91,7 @@ program
9091
AWS_DLQ_TARGET_ARN)
9192
.option('-c, --tracingConfig [AWS_TRACING_CONFIG]', 'Lambda tracing settings',
9293
AWS_TRACING_CONFIG)
94+
.option('-l, --layers [AWS_LAYERS]', 'Lambda Layers settings', AWS_LAYERS)
9395
.option('-R, --retentionInDays [AWS_LOGS_RETENTION_IN_DAYS]', 'CloudWatchLogs retentionInDays settings',
9496
AWS_LOGS_RETENTION_IN_DAYS)
9597
.option('-A, --packageDirectory [PACKAGE_DIRECTORY]', 'Local Package Directory', PACKAGE_DIRECTORY)

lib/main.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ so you can easily test run multiple events.
215215
},
216216
TracingConfig: {
217217
Mode: null
218-
}
218+
},
219+
Layers: []
219220
}
220221

221222
if (this._isUseS3(program)) {
@@ -252,6 +253,9 @@ so you can easily test run multiple events.
252253
if (program.tracingConfig) {
253254
params.TracingConfig.Mode = program.tracingConfig
254255
}
256+
if (program.layers) {
257+
params.Layers = program.layers.split(',')
258+
}
255259

256260
return params
257261
}
@@ -538,7 +542,8 @@ so you can easily test run multiple events.
538542
'Environment': params.Environment,
539543
'KMSKeyArn': params.KMSKeyArn,
540544
'DeadLetterConfig': params.DeadLetterConfig,
541-
'TracingConfig': params.TracingConfig
545+
'TracingConfig': params.TracingConfig,
546+
'Layers': params.Layers
542547
}, (err, data) => {
543548
if (err) return reject(err)
544549
resolve(data)

test/main.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const originalProgram = {
2323
runtime: 'nodejs8.10',
2424
deadLetterConfigTargetArn: '',
2525
tracingConfig: '',
26+
Layers: '',
2627
retentionInDays: 30,
2728
region: 'us-east-1,us-west-2,eu-west-1',
2829
eventFile: 'event.json',
@@ -298,6 +299,18 @@ describe('lib/main', function () {
298299
assert.isNull(params.TracingConfig.Mode)
299300
})
300301

302+
it('appends Layers to params when params set', () => {
303+
program.layers = 'Layer1,Layer2'
304+
const params = lambda._params(program)
305+
assert.deepEqual(params.Layers, ['Layer1', 'Layer2'])
306+
})
307+
308+
it('does not append Layers when params are not set', () => {
309+
program.layers = ''
310+
const params = lambda._params(program)
311+
assert.deepEqual(params.Layers, [])
312+
})
313+
301314
describe('S3 deploy', () => {
302315
it('Do not use S3 deploy', () => {
303316
const params = lambda._params(program, 'Buffer')

0 commit comments

Comments
 (0)