aws / aws/chalice

Deploying with layers and dependents over-provisions packages in .zip file

Open
#1,208 5 comments 1 reaction 0 assignees View on GitHub
enhancement needs-discussion
Dominant language
Python
Stars
11.1k
Forks
1k
Avg merge
1d 22h
Merged PRs (30d)
2

Description

I'm trying to deploy with the official AWS SciPy layer, but another of the packages in my `requirements.txt` has `scipy` as a dependency. This seems to cause SciPy to get packaged up in the final .zip file, negating the point of using the layer in the first place (and pushing me over the size limit).

---

Reproduction steps:

`app.py`:
```
from chalice import Chalice
import scipy

app = Chalice(app_name='layer-test')

@app.route('/')
def index():
return {'version': scipy.__version__}
```

`.chalice/config.json`:
```
{
"version": "2.0",
"app_name": "layer-test",
"stages": {
"prod": {
"api_gateway_stage": "api",
"lambda_functions": {
"api_handler": {
"layers": [
"arn:aws:lambda:eu-west-1:399891621064:layer:AWSLambda-Python36-SciPy1x:2"
]
}
}
}
}
}
```

(note you can also use `arn:aws:lambda:us-east-1:668099181075:layer:AWSLambda-Python36-SciPy1x:2` for the same layer, if you prefer).

Leave `requirements.txt` blank and run:

chalice package --stage prod /tmp/packaged

If you check the .zip generated, you can see that scipy is not in there (as expected).

However, if we add e.g. `scikit-criteria` to `requirements.txt` and then run `chalice package` again, the .zip now contains the (quite large) SciPy package :(

---

I suppose I can work around this by making my own layer for `scikit-criteria`, but is there any way to fix it in Chalice? As far as I know, `requirements.txt` doesn't support any kind of 'no dependencies' flag, so maybe it's not so simple.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with app.py, .chalice/config.json, and a blank requirements.txt, then run chalice package --stage prod /tmp/packaged and inspect the generated zip. Add scikit-criteria to requirements.txt and compare the dependency packaging; done means a dependency on scipy does not include scipy when the configured AWS layer supplies it, without breaking required packages.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.