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

Environment variables are not available #83

Open
frankTurtle opened this issue Apr 12, 2018 · 6 comments
Open

Environment variables are not available #83

frankTurtle opened this issue Apr 12, 2018 · 6 comments

Comments

@frankTurtle
Copy link

  • Testing lambda function
  • trying to call process.env.variableName
  • getting undefined
  • printed out environment variables, they're not in the list
  • environment variables are accessible in regular serverless mocha tests, just not lambda functions.
@jplock
Copy link

jplock commented May 15, 2018

Just ran into this myself. Are there any workarounds?

@hazrul
Copy link

hazrul commented May 23, 2018

I am facing the same issue. Getting undefined for environment variables

@Thana404
Copy link

Thana404 commented Dec 28, 2018

I know this issue is a bit old, but I'm too facing it, but only for a specific use case.
Basically, any environment variable defined in the "provider" can be retrieved properly using "process.env":

But any environment variable defined at a function level cannot.

provider
  environment:
    FOO: foo <-- I can get it in my tests with process.env
functions:
  MyFunction:
    environment:
      BAR: bar <-- I cannot

For now I duplicate this function's env. variables in a dedicated json file, but being able to not duplicate them (and risk out-of-sync issue) would be great.

@xyklex
Copy link

xyklex commented Sep 10, 2019

I'm having this same issue with cf variables being not populated on sls version: 1.51.0.

// variable in serverless.yaml
custom:
  DeviceDatabase: ${cf.us-west-1:my-stack.DeviceDatabase}

As this issue is is from 2018 I don't know if this plugin is still in support

@KariHe
Copy link
Contributor

KariHe commented Nov 25, 2019

provider
  environment:
    FOO: foo <-- I can get it in my tests with process.env
functions:
  MyFunction:
    environment:
      BAR: bar <-- I cannot

I did some testing and this seems to work as expected with latest version of the plugin and sls v1.58.0. I got both environment variables into the lambda.

@KariHe
Copy link
Contributor

KariHe commented Nov 25, 2019

I'm having this same issue with cf variables being not populated on sls version: 1.51.0.

// variable in serverless.yaml
custom:
  DeviceDatabase: ${cf.us-west-1:my-stack.DeviceDatabase}

I will try to test this scenario. I'm not sure when Cloudformation references are resolved or are they handled actually the Cloudformation deployment.

As this issue is is from 2018 I don't know if this plugin is still in support

We currently don't have a much time to support these plugins, so we appreciate contributions to resolve the issues.

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

6 participants