DieProduktMacher / serverless-env-generator

A Serverless 1.x plugin to manage environment variables with YAML and turn them into a .env file on deployment. Supports encryption with KMS, multiple stages and custom profiles.
MIT License
31 stars 11 forks source link

.env being removed after being generated #11

Open kraiovsky opened 5 years ago

kraiovsky commented 5 years ago

running

> sls env generate

first creates and then removes just generated .env. Sample output:

Serverless: DOTENV: Could not find .env file.
Serverless: Creating .env file...
Serverless: Removed .env file

same happens for sls package and other commands which seems to be expected according to after:deploy hooks, but shouldn't happen for a manual generation?

Running serverless v1.51.0

kraiovsky commented 5 years ago

Looked through the code and it seems to be working as designed. In my case, though, I run the app both as a server (with Koa + serverless-http) and as a Lambda function. I keep env variables in environment.yml, generate single .env which is used by both. So, keeping .env file is important.

I created a pull request to accept an option sls env generate -keepEnvFile to keep it: https://github.com/DieProduktMacher/serverless-env-generator/pull/12

tlimp commented 5 years ago

Thing is, it's kind of going against the purpose of having no unencrypted credentials longer than necessary on your file system. We'll have a look into it and coming back to you as soon as possible.

jim-spot commented 3 months ago

In my case I need the ability to use secrets in a Lambda@Edge function. Since it doesn't support environment variables, the only way you can really get this to work is to include a .env file with the deployment. I think a -packageEnvFile option would be really nice to have in this case.