I use serverless framework and I have multilple aws node.js lambdas that share the same layer. I want to define an ENV variable for all of them-is there a way to put that common ENV variable into the layer's serverless.yml? Or do I have to go and put it in each serverles.yml files separately?
-
Put them in a common file and import that common file into each deployment's serverless.yml template? See serverless.com/framework/docs/providers/aws/guide/variables/…jarmod– jarmod2020-03-26 14:46:57 +00:00Commented Mar 26, 2020 at 14:46
-
@Capaj were you able to find a satisfactory solution for environment vars in layers?trdavidson– trdavidson2020-11-09 16:49:48 +00:00Commented Nov 9, 2020 at 16:49
-
@trdavidson yeah we're using serverless-dotenv-plugin and it works fine for our fleet of lambdasCapaj– Capaj2021-03-12 10:25:17 +00:00Commented Mar 12, 2021 at 10:25
-
Thanks @Capaj will check it outtrdavidson– trdavidson2021-03-12 11:25:33 +00:00Commented Mar 12, 2021 at 11:25
Add a comment
|
1 Answer
To deal with env variables in my lambdas i use this plugin https://www.npmjs.com/package/serverless-dotenv-plugin
It looks for a .env file use it as a reference to your env variables.
plugins:
- serverless-dotenv-plugin
Hope it helps.