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

Allow to run functions with env variables correctly populated

Open marcosnils opened this issue 8 years ago • 1 comments

My lambda functions use process.env to read variables configured from the environment. They currently crash because functions are not populating this variables correctly.

This PR calls the Runtime.run function which properly initializes env variables for the specific function.

note: if multiple functions use the same env variables and functions are executed concurrently, unknown errors may happen as process.env will be modified nondeterministically

marcosnils avatar Apr 20 '16 22:04 marcosnils

@marcosnils populating env from s-function.json can be made optional, but it'll be painful to make it mandatory; see my comments inline.

note: you're right on different env for each function; AFAIR it wasn't possible with older sls. IMO it's not a piece of cake to have this supported in serverless-serve under current design, anyway you may try if you'd like to.

tszajna0 avatar Apr 21 '16 07:04 tszajna0