I want to locally test a lambda function that uses a lambda layer.
This is my template:
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
MyLambdaFunction:
Type: 'AWS::Serverless::Function'
Properties:
Handler: index.handler
Runtime: python3.8
CodeUri: pathToFunction
Layers:
- !Ref MyLayer
MyLayer:
Type: 'AWS::Serverless::LayerVersion'
Properties:
LayerName: mylayer
Description: My Lambda layer for payment handling
ContentUri: projectRoot/amplify/backend/function/myLambdaLayer
CompatibleRuntimes:
- python3.8
When i do sam invoke local -e event.json MyLambdaFunction
it says it cannot find the modules that are in the lambda layer.
On the cloud, testing the function works and I use the same layer. What is happening?