question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sam local Invoke lambda with local layer error

See original GitHub issue

Description:

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:

  1. Have a larger than 10MB layer (maybe more, just took the recommended max size from AWS console)
  2. Import layer’s package and run sam local invoke FunctionName
  3. Deploy the layer manually in AWS console
  4. Run sam local invoke FunctionName again after changing the lambda’s layers property to the remote ARN in template.yaml.

Observed result:

Failure when calling Layer locally:

Screenshot from 2019-05-17 11-20-40

Screenshot from 2019-05-17 11-20-55

Expected result:

Calling layer locally or from remote have the same output.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
jfusscommented, Oct 9, 2019

@Cecarlego We support layers that are local as well, just not ones that are already zipped. The value of Content or ContentUri (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.

3reactions
jfusscommented, Aug 26, 2019

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found