bug: environment messed up
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.
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.
Prepared PR to fix this issue - https://github.com/trek10inc/serverless-secrets/pull/38.