Skip to content

Commit 55cc12f

Browse files
committed
Support invoking aws-lambda with layers
1 parent c932778 commit 55cc12f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Diff for: serverless.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const defaults = {
4141
handler: 'handler.hello',
4242
runtime: 'nodejs10.x',
4343
env: {},
44-
region: 'us-east-1'
44+
region: 'us-east-1',
45+
layers: []
4546
}
4647

4748
class AwsLambda extends Component {

Diff for: utils.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable prettier/prettier */
12
const { tmpdir } = require('os')
23
const path = require('path')
34
const archiver = require('archiver')
@@ -76,7 +77,8 @@ const createLambda = async ({
7677
zipPath,
7778
bucket,
7879
role,
79-
layer
80+
layer, // From autogenerated layer
81+
layers // Manual layers
8082
}) => {
8183
const params = {
8284
FunctionName: name,
@@ -90,11 +92,13 @@ const createLambda = async ({
9092
Timeout: timeout,
9193
Environment: {
9294
Variables: env
93-
}
95+
},
96+
Layers: layers
9497
}
9598

99+
96100
if (layer && layer.arn) {
97-
params.Layers = [layer.arn]
101+
params.Layers = [layer.arn, ...layers]
98102
}
99103

100104
if (bucket) {
@@ -119,7 +123,8 @@ const updateLambdaConfig = async ({
119123
env,
120124
description,
121125
role,
122-
layer
126+
layer, // From autogenerated layer
127+
layers // Manual layers
123128
}) => {
124129
const functionConfigParams = {
125130
FunctionName: name,
@@ -131,11 +136,12 @@ const updateLambdaConfig = async ({
131136
Timeout: timeout,
132137
Environment: {
133138
Variables: env
134-
}
139+
},
140+
Layers: layers
135141
}
136142

137143
if (layer && layer.arn) {
138-
functionConfigParams.Layers = [layer.arn]
144+
functionConfigParams.Layers = [layer.arn, ...layers]
139145
}
140146

141147
const res = await lambda.updateFunctionConfiguration(functionConfigParams).promise()

0 commit comments

Comments
 (0)