@nicholaskuchiniski/serverless-dotenv-plugin
v2.0.1
Published
Serverless plugin template
Downloads
9
Maintainers
Readme
@nicholaskuchiniski/serverless-dotenv-plugin
Create .env files on your serverless function using serverless.yaml definition
Why ?
The main objective of this library is to get out of the lambda limit 4KBs problem, using the serverless.yaml definitions to assemble the .env file (allowing to get variables through SSM, etc.). Keep in mind that putting a .env in your lambda, also means putting all your environment variables in a readable way inside your lambda .zip, so be careful.
Usage
Install the plugin with
yarn add -D @nicholaskuchiniski/serverless-dotenv-plugin
Add the plugin on you serverless.yaml:
plugins: - "@nicholaskuchiniski/serverless-dotenv-plugin"
Create a custom definition on your serverless.yaml:
custom: dotenv: API_URL: http://api-url.example.com
Run
serverless dotenv
, a .env file will be created on the root your actual directory and serverless will put it inside your lambda (is important to have dotenv propertly configured inside your code)
Example
Inside the main repository, a /example exists with a simple serverless function that shows a value from the .env file.