Fix corrupted zip archive in case of same module #181
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
We have different functions with different runtime (not only python) defined in serverless.yml.
For python runtime, there are several functions defined in one file with same dependencies.
To be able to build a package, I have to specify the
module
param, since requirements for our python functions are not placed in a root folder of the project.Project structure (simplified):
In
api/users/handlers.py
we have several functions:serverless.yaml (some directives are omitted for simplicity):
As you can see, both func1 and func2 are declared in same python file, but these are different lambda functions. And they have same dependencies, i.e. same requirmemnts.txt file. We found such code structure useful.
When I try to create a package:
The resulting archive in
.serverless/api/users.zip
is corrupted. I suppose the reason is that serverless-python-requirements creates zip archives for different functions asynchronously. Since both functions have same module path - they have same artifact archive.I can't unzip it and deploy is not working as well.
The archive is fine when I delete func2 from serverless.yml.
Solution
The easiest solution that comes to my mind is to include func name to the artifact zip archive. In that way it works well.