Skip to content
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

invoke local docker does not include dependencies added by plugins #5947

endeepak opened this Issue Mar 21, 2019 · 1 comment


None yet
2 participants
Copy link

endeepak commented Mar 21, 2019

This is a Bug Report


This issue happens when using plugin serverless-python-requirements to ensure dependencies defined in requirements.txt are included in the lambda package

  • What went wrong?
    sls invoke local --docker doesn't include the dependencies and the lambda fails to import the dependencies

  • What did you expect should have happened?
    sls invoke local --docker should add the dependencies added by plugin to docker container so that lambda can import them successfully

  • What was the config you used?

service: dependency-bug

  name: aws
  runtime: python2.7

    handler: handler.hello

  - serverless-python-requirements

import os
import dns.resolver

def hello(event, context):
    return "hello"
  • What stacktrace or error message from your provider did you see?
➜  env-var-bug sls invoke local -f hello
➜  env-var-bug sls invoke local -f hello --docker
Serverless: Building Docker image...
START RequestId: 9fcc8921-a77c-4578-bc35-1660bf3eb244 Version: $LATEST

Unable to import module 'handler': No module named dns.resolver
END RequestId: 9fcc8921-a77c-4578-bc35-1660bf3eb244

REPORT RequestId: 9fcc8921-a77c-4578-bc35-1660bf3eb244 Duration: 5 ms Billed Duration: 100 ms Memory Size: 1536 MB Max Memory Used: 14 MB

{"errorMessage": "Unable to import module 'handler'"}

  Error --------------------------------------------------


     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.11.0
     Serverless Version:     1.39.1

Similar or dependent issues:

Additional Data

  • Serverless Framework Version you're using: 1.39.1
  • Operating System: mac OSX High Sierra
  • Stack Trace: Provided Above
  • Provider Error messages: Provided Above

This comment has been minimized.

Copy link
Contributor Author

endeepak commented Mar 21, 2019

Possible solution: Update invokeLocal command to do following steps after building the docker image

endeepak added a commit to endeepak/serverless that referenced this issue Mar 29, 2019

endeepak added a commit to endeepak/serverless that referenced this issue Apr 2, 2019

endeepak added a commit to endeepak/serverless that referenced this issue Apr 4, 2019

@pmuens pmuens closed this in #5977 Apr 9, 2019

pmuens added a commit that referenced this issue Apr 9, 2019

Merge pull request #5977 from endeepak/bugfix/5947_invoke_local_handl…

#5947: Ensure invoke local docker runs lambda with the dependencies

killev added a commit to killev/serverless that referenced this issue Apr 17, 2019

Merge commit '10b7d722502d65b0f628d3f23929f0a450ec6cbd'
* commit '10b7d722502d65b0f628d3f23929f0a450ec6cbd': (132 commits)
  updated newsletter link in readme
  add enterprise link to readme
  Add support for multiple usage plans
  Fix tests
  Update docs
  Add check for breaking changes
  Remove custom stack error messages
  add layers to gblobal sls yaml examle indocs
  Update other Node.js-based templates
  Make JSON.stringify easy on the eyes
  Add strict mode declarative
  Updating Node.js runtime version
  Allow specifying a retention policy for lambda layers
  Add custom error message when X-Ray tracing deployments fail
  Update docs with note about CloudFormation limitations
  serverless#5947: Handle creation of files under subfolder name starting with dot
  eslint: Mark as root config
  Lint fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.