nordcloud / serverless-mocha-plugin

Plugin for Serverless Framework which adds support for test-driven development using Mocha
MIT License
159 stars 50 forks source link

Environment variables are not available #83

Open frankTurtle opened 6 years ago

frankTurtle commented 6 years ago
jplock commented 6 years ago

Just ran into this myself. Are there any workarounds?

hazrul commented 6 years ago

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

Thana404 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago
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 commented 5 years ago

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.