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

Closed
endeepak opened this issue Mar 21, 2019 · 1 comment · Fixed by #5977
Closed

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

endeepak opened this issue Mar 21, 2019 · 1 comment · Fixed by #5977

Comments

@endeepak
Copy link
Contributor

This is a Bug Report

Description

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?
    serverless.yml

service: dependency-bug

provider:
  name: aws
  runtime: python2.7

functions:
  hello:
    handler: handler.hello

plugins:
  - serverless-python-requirements

handler.py

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
"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 --------------------------------------------------

  1

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

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  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
@endeepak
Copy link
Contributor Author

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 added a commit that referenced this issue Apr 9, 2019
…e_dependency

#5947: Ensure invoke local docker runs lambda with the dependencies
killev added a commit to killev/serverless that referenced this issue Apr 17, 2019
* commit '10b7d722502d65b0f628d3f23929f0a450ec6cbd': (132 commits)
  updated newsletter link in readme
  add enterprise link to readme
  Add support for multiple usage plans
  Update quick-start.md
  Update quick-start.md
  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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants