6

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?

4
  • 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/… Commented Mar 26, 2020 at 14:46
  • @Capaj were you able to find a satisfactory solution for environment vars in layers? Commented Nov 9, 2020 at 16:49
  • @trdavidson yeah we're using serverless-dotenv-plugin and it works fine for our fleet of lambdas Commented Mar 12, 2021 at 10:25
  • Thanks @Capaj will check it out Commented Mar 12, 2021 at 11:25

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.