serverless-serve
serverless-serve copied to clipboard
Allow to run functions with env variables correctly populated
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 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.