-
Notifications
You must be signed in to change notification settings - Fork 293
Package individually example does not work #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Actually, it seem that the problem is trying to |
I discovered why I got the following error:
When I use the following config, package:
individually: true
functions:
func1:
handler: index.handler
module: function1
package:
include:
- 'function1/*.py' It generates the following structure on AWS Lambda: And everything works as expected, but when using custom:
pythonRequirements:
zip: true
package:
individually: true
functions:
func1:
handler: index.handler
module: function1
package:
include:
- 'function1/*.py' It changes the folder structure to: So, I had to update my config to match the folder structure: functions:
func1:
handler: function1/index.handler
module: function1
package:
include:
- 'function1/*.py' But, the code that os.environ.get('LAMBDA_TASK_ROOT', os.getcwd()), '.requirements.zip')
// Unable to import module 'function1/index': No module named 'langdetect' |
aha. Good job tracking that down! Should be a relatively easy fix. |
This PR fixes two issues I encountered while using `individually: true` option. **1. Should package only the given function when invoked by `sls deploy function --function $FN_NAME`** Suppose using `individually: true`. If you'd like to deploy a single function using `sls deploy function` command you'd expect the plugin to package only the module that contains the function specified. The current implementation, however, runs packaging for every module in `serverless.yml` definition, taking as much time as deploying all applications just to deploy a single function. I simply added explicit `targetFuncs` property to filter target function if any specified in command line option. **2. `moveModulesUp` should be called regardless of `zip` option** When `individually: true`, each deployed function has its module as a root directory. This is achieved by calling `moveModulesUp`, but this method call is ignored when `zip` option is enabled. This certainly seems to be a wrong implementation (causing #203). If `injectModule` is ensured not to be called when `zip: true`, it is safe to call `moveModulesUp` whether `zip` is enabled or not. The fix seems to work well on my case, but it lacks new unit tests (I couldn't figure out how to compose one.) If you let me known how to add a test, I'll update the PR as soon as I can.
Yup. Thanks for following up! |
The value of |
Hi, I followed the documentation on how to package individually, but it seems that is not working. Here's my
serverless.yml
, closely matching the example on README:And here's my folder structure:
When I make a request to the
func1
orfunc2
I get an internal server error with the following logs onboth
functions:I wonder what I'm doing wrong. Thanks!
The text was updated successfully, but these errors were encountered: