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

Some, not all, environment vars are missing #99

Closed
bebbi opened this issue Feb 14, 2017 · 5 comments
Closed

Some, not all, environment vars are missing #99

bebbi opened this issue Feb 14, 2017 · 5 comments

Comments

@bebbi
Copy link

bebbi commented Feb 14, 2017

Environment variables are not all available to functions. Only the variables defined globally and those for the first function will be available when running locally. Example:

serverless.yml:

provider:
  environment:
    A: 'A'
functions:
  func1:
    environment:
      F1: '1'
  func2:
    environment:
      F2: '2'

In this setup, the only variables available to the local environment are A and F1.
If I move func2 on top of func1, it is however A and F2.

@bebbi
Copy link
Author

bebbi commented Feb 15, 2017

I found why this is happening.

webpack has created a single handler.js function containing both functions, which means that at set up time of func1, func2 is also loaded which immediately leads to a failure as func2 needs its environment but doesn't have it available.

@kevinold
Copy link

I tested this with my project and unfortunately I'm still missing all environment variables in my handlers :(

@HyperBrain
Copy link
Member

@bebbi Version 3.0.0 will integrate with serverless invoke local and the serve command will be removed in favor of the serverless-offline plugin (see Milestone 3.0.0). This should also fix the environment variable issue completely.
My PR #153 already works - only the unit tests are missing. Could you try it with that and tell me, if it works as expected?

@HyperBrain
Copy link
Member

serve will be removed in the next v3.0.0 release in favor of serverless-offline (see #152 ). No efforts will be spent on the function anymore. So I'll close this issue.

@bebbi
Copy link
Author

bebbi commented Jul 28, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants