Serverless-python-requirements: Running individually packaged functions locally

Created on 2 Aug 2018  路  2Comments  路  Source: UnitedIncome/serverless-python-requirements

I have a Python function I'm individually packaging with requirements with a config like

plugins:
  - serverless-python-requirements
package:
  individually: true
functions:
  hello:
    handler: handler.lambda_handler
    module: func1

With a file structure like

serverless.yml
func1/
  __init__.py
  handler.py
  requirements.txt

I can deploy this function and it works fine, but when I try to invoke it locally, it fails. It looks like it doesn't do anything with the module, and just tries to run handler.lambda_handler instead of ./func1.handler.lambda_handler. If I change handler to func1.handler.lambda_handler, it runs locally, but obviously would fail when deployed.

Is there something I'm missing to make this work, or is this something that's possible to do with this plugin?

bug

Most helpful comment

good catch. @cgrimal, i think we could fix this by tapping in to the invoke local event and modifying functions.FUNCNAME.handler by prepending functions.FUNCNAME.module if it's set. Does that sound reasonable?

All 2 comments

good catch. @cgrimal, i think we could fix this by tapping in to the invoke local event and modifying functions.FUNCNAME.handler by prepending functions.FUNCNAME.module if it's set. Does that sound reasonable?

For anyone else who arrives here from Google - Note that there are at least a couple of hacky workarounds to this issue: https://github.com/UnitedIncome/serverless-python-requirements/issues/520#issuecomment-648001384

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amadensor picture amadensor  路  3Comments

sepulworld picture sepulworld  路  5Comments

davegravy picture davegravy  路  5Comments

simplesteph picture simplesteph  路  5Comments

doublemarked picture doublemarked  路  3Comments