Skip to content

Commit 0181d9d

Browse files
committed
Add Lambda Layer argument
1 parent 3dee69e commit 0181d9d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/sagemaker/lambda_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(
3939
vpc_config: dict = None,
4040
architectures: list = None,
4141
environment: dict = None,
42+
layers: list = None,
4243
):
4344
"""Constructs a Lambda instance.
4445
@@ -73,6 +74,7 @@ def __init__(
7374
architectures (list): Which architecture to deploy to. Valid Values are
7475
'x86_64' and 'arm64', default is None.
7576
environment (dict): Environment Variables for the Lambda function. Default is None.
77+
layers (list): List of Lambda layers for the Lambda function. Default is None.
7678
"""
7779
self.function_arn = function_arn
7880
self.function_name = function_name
@@ -88,6 +90,7 @@ def __init__(
8890
self.vpc_config = vpc_config
8991
self.environment = environment
9092
self.architectures = architectures
93+
self.layers = layers
9194

9295
if function_arn is None and function_name is None:
9396
raise ValueError("Either function_arn or function_name must be provided.")
@@ -140,6 +143,7 @@ def create(self):
140143
VpcConfig=self.vpc_config,
141144
Environment=self.environment,
142145
Architectures=self.architectures,
146+
Layers=self.layers,
143147
)
144148
return response
145149
except ClientError as e:

tests/unit/test_lambda_helper.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def test_create_lambda_happycase1(sagemaker_session):
190190
Architectures=None,
191191
VpcConfig=None,
192192
Environment=None,
193+
Layers=None,
193194
)
194195

195196

@@ -218,6 +219,7 @@ def test_create_lambda_happycase2(sagemaker_session):
218219
Architectures=None,
219220
VpcConfig=None,
220221
Environment=None,
222+
Layers=None,
221223
)
222224

223225

@@ -235,6 +237,7 @@ def test_create_lambda_happycase3(sagemaker_session):
235237
"SubnetIds": ["test-subnet-1"],
236238
"SecurityGroupIds": ["sec-group-1"],
237239
},
240+
layers=["my-test-layer-1", "my-test-layer-2"],
238241
)
239242

240243
lambda_obj.create()
@@ -251,6 +254,7 @@ def test_create_lambda_happycase3(sagemaker_session):
251254
Architectures=["x86_64"],
252255
VpcConfig={"SubnetIds": ["test-subnet-1"], "SecurityGroupIds": ["sec-group-1"]},
253256
Environment={"Name": "my-test-lambda"},
257+
Layers=["my-test-layer-1", "my-test-layer-2"],
254258
)
255259

256260

@@ -424,6 +428,7 @@ def test_upsert_lambda_happycase1(sagemaker_session):
424428
Architectures=None,
425429
VpcConfig=None,
426430
Environment=None,
431+
Layers=None,
427432
)
428433

429434

0 commit comments

Comments
 (0)