serverless-secrets icon indicating copy to clipboard operation
serverless-secrets copied to clipboard

bug: environment messed up

Open franciscocpg opened this issue 8 years ago • 2 comments

Giving the following serverless configuration

function1:
  handler: file1.handler
  environmentSecrets:
      ENV1: '/my-project/${opt:stage}/ENV1'

function2:
  handler: file2.handler
  environmentSecrets:
      ENV2: '/my-project/${opt:stage}/ENV2'

When invoking function1 the environment is injected with ENV2 variable instead of ENV1. And that's because of the the code below: https://github.com/trek10inc/serverless-secrets/blob/948e5db949dc63cc0b2cac6486c1a5c9c41e9589/plugin/index.js#L240-L247

I've done a fix for me (https://github.com/franciscocpg/serverless-secrets/commit/19140522150c3e9aeac16c879e586d6ceb607964) and it worked the way I've expected but before proposing a PR I'd like to know the rationale behind this split.

Maybe there is something I'm not seeing.

franciscocpg avatar Dec 15 '17 10:12 franciscocpg

Thank you for the plugin.

When all functions have same handler is another case where environment is messed up. Below is the sample config.

function1: handler: file.handler environment: ENV1: 'fn1 env1 value' environmentSecrets: ENVSECRET1: '/my-project/${opt:stage}/ENVSECRET1'

function2: handler: file.handler environment: ENV1: 'fn2 env1 value' environmentSecrets: ENVSECRET1: '/my-project/${opt:stage}/ENVSECRET2'

If we can generate environments object by function name instead, it would be a more generic fix.

sneha-nagole avatar Jun 06 '18 00:06 sneha-nagole

Prepared PR to fix this issue - https://github.com/trek10inc/serverless-secrets/pull/38.

sneha-nagole avatar Jun 19 '18 18:06 sneha-nagole