aws / aws/aws-sam-cli

Sam local Invoke lambda with local layer error

Open
#1,187 13 comments 3 reactions 0 assignees View on GitHub
area/layers maintainer/need-followup priority/2-important stage/needs-investigation type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

**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](https://user-images.githubusercontent.com/47978155/57921701-e50ff800-7895-11e9-8291-5b5bd4c3f050.png)

![Screenshot from 2019-05-17 11-20-55](https://user-images.githubusercontent.com/47978155/57921712-eccf9c80-7895-11e9-99b3-81d6c93b64f8.png)

**Expected result:**

Calling layer locally or from remote have the same output.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.