Sam local Invoke lambda with local layer error
See original GitHub issueDescription:
When invoking a function locally, which relies on a layer built locally as well, the function cannot find the module which is part of the layer. When uploading that layer through the AWS console, and changing the Layer’s reference in the template.yaml file, the import works. The layer is 17Mb zipped, and contains the mysql-connector-python module, as well as the requests module.
Steps to reproduce the issue:
- Have a larger than 10MB layer (maybe more, just took the recommended max size from AWS console)
- Import layer’s package and run
sam local invoke FunctionName
- Deploy the layer manually in AWS console
- Run
sam local invoke FunctionName
again after changing the lambda’s layers property to the remote ARN intemplate.yaml
.
Observed result:
Failure when calling Layer locally:
Expected result:
Calling layer locally or from remote have the same output.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Sam local Invoke lambda with local layer error · Issue #1187
Description: When invoking a function locally, which relies on a layer built locally as well, the function cannot find the module which is ......
Read more >Sam local Invoke lambda with local layer error "unable to ...
I am getting the error "unable to import package" error while invoking my lambda locally using 'sam local invoke FUNCTIONNAME'. Those packages ...
Read more >sam local invoke - AWS Serverless Application Model
Invoke a local Lambda function using the sam local invoke command from the AWS SAM CLI.
Read more >SAM Local Invoke: Layer endpoint not found | AWS re:Post
Hi, I'm trying to set up a local dev environment for my Lambda functions using SAM. I had everything working until I added...
Read more >Invoking AWS Lambda functions locally using AWS SAM CLI
You will need to install AWS CLI, AWS SAM CLI and Docker to invoke a Lambda function locally. If you already have AWS...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Cecarlego We support layers that are local as well, just not ones that are already zipped. The value of
Content
orContentUri
(depending on the resource you are using for Layers), should be the directory to where the code is and be unzipped. If that is true, then we will pick up that layer, combine it with any other layers for the function and make it available in the container.@indyfin DO NOT do that. The vendored requests library is old and not updated, see https://github.com/boto/botocore/issues/1745#issuecomment-497833200 and https://github.com/boto/botocore/issues/1608