aws-amplify / aws-amplify/amplify-hosting

Deployment of Python Lambdas Virtual Env Missing lib64

Open
#2,946 0 comments 0 reactions 0 assignees View on GitHub
usability
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### App Id

_No response_

### Region

_No response_

### Amplify Hosting feature

Backend builds

### Describe the bug

For a python lambda function, when the virtual environment get's zipped up, it only deploys the packages under `lib/pythonX.X/site-packages/*`. However, packages are also installed under `lib64/pythonX.X/site-packages/*`. As a result, not all packages in the lambda environment will be deployed.

### Expected behavior

All packages in the Pipfile should be deployed to the lambda environment

### Reproduction steps

1. Define a Pipfile to include `pandas`
2. Try to deploy a lambda function that just imports `pandas`
3. On deployment, the function should fail
4. Similarly, you can check the s3 virtual env zip to verify that pandas was not zipped up properly.

### Build Settings

```yaml
- Amazon Linux 2
- Python 3.8
```

### Additional information
The current hack I have around this solution is to `pipenv install` manually first for a new lambda function and the manual `cp` the packages from `lib64` to `lib`. Then on deployment, it will automatically include the `lib64` packages. Ideally, this could be integrated directly into the `amplify push` build process.

Contributor guide

Open the contributing guide

Research direction

Start with the amplify push build process and the packaging step that creates the S3 virtual-environment zip; the issue provides no source file or test name. Reproduce with a Python 3.8 Lambda whose Pipfile includes pandas, inspect the resulting zip, and verify that all packages required by the function are deployed.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
backend, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.