Closed coyoteecd closed 3 years ago
This seems like a useful feature request. I'm not perfectly sure how we could achieve this, e.g. we would need to create .env
files for every function, but I'm happy to look into any future pull requests trying to tackle this.
v2.0.0 allows to export environment variables for a specific function only. To simplify testing the new version, I've published 2.0.0-alpha.0
as alpha release to npm
:
npm install serverless-export-env@2.0.0-alpha.0 --save-dev
I'm closing this task. Please open a new one (or comment on this one) if your problems are still not solved.
The plugin seems to assume that environment variable names are unique across all functions in the serverless.yml stack and lumps them together in a name=value list within .env file. This may or may not be the case in practice.
Example serverless.yml:
With the plugin, invoking one-function shows process.env.test as
two
. Without the plugin, process.env.test is correctly set toone
.