Where to put "useDotenv: true" in serverless.yml file?
Asked Answered
S

1

17

I was using serverless templates and all worked fine until suddenly all my deployments started ignoring .env files.

I searched through the documentation and it says that if I want to use the environment variables from .env files I now have to add useDotenv: true in my serverless.yml file. So I did:

app: xxx
org: xxx
useDotenv: true 

There was no effect.

My serverless.yml file contained nothing else before but the app and org variables.

Where do I need to add the seDotenv: true in order to make it read my .env variables?

Sines answered 18/2, 2021 at 5:34 Comment(2)
It needs to go right in the same level where your service definition is, e.g. service: my-service then next line on that level add useDotenv: true. Which Serverless version are you using?Ambassadress
Thank you for your reply! The accepted answer is the one I was looking for.Sines
R
25

You should put it at the root of your serverless.yml file.

I have mine just after the service attribute :

service: lb-courses
useDotenv: true
plugins:
  - serverless-offline
...
Revisory answered 21/2, 2021 at 15:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.