This is not my first app with Serverless, but it is my first time with this issue.
My yaml is a replica of the 2 other functional yaml files, obviously modified for the application. It has previously deployed as expected. I’m working on a new function which, to start only returns the event and has no imports. When deploying, I was repeatedly encountering the “must be under this size” error, and on inspecting the .serverless folder and then the zipped function inside, I see that each one contains ALL of the other functions and files and packages.
Each function handler:
is foo.foo, bar.bar, etc.
I have package: individually: true
and my patterns:
includes all the expected exclusions (env, .git, .serverless, etc.). At this time, my root folder contained all the function files and a helper file used by all.
I’ve since moved each function file into a folder, so folder foo
contains foo.py
where you’ll find the function foo()
, and the helper is now in a folder called shared
. I’ve modified my yaml to have package: individually: true
at the top level, and then each function now has package: patterns: "!**/*", "foo/foo.py", "shared/"
The good news - each zip contains the folders foo
and shared
, and unzip_requirements.py
and is plenty small.
The bad news - the lambdas don’t run. I get this error - “errorMessage”: “Handler ‘foo’ missing on module ‘foo’”.
I’ve also tried having the function handler:
as foo/foo.foo
and foo.foo.foo
. Those return a different error, “Runtime.ImportModuleError: Unable to import module ‘getGPGKeys.getGPGKeys’: attempted relative import beyond top-level package”
I’ve changed the patterns:
to include foo/foo.py
and that still puts the whole foo
folder inside the zip and gets the same error.
Again, this is not an issue I’ve had with my other projects. I have never needed to put each function in a folder and have this per-function package instruction. I don’t have any ideas left on how to make this work, and it’s now a 3-day block on getting my work done.