neverendingqs / serverless-dotenv-plugin

Preload Environment Variables with Dotenv into Serverless

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

custom path does not support variables

andidev opened this issue · comments

for example this works for me:

path: .env.dev

but this does not

path: .env.${'dev'}

+1 on this one.
I would love to be able to do something like this:

dotenv:
    path: 'deployment/${self:provider.stage}/.env'

I think you might find more mileage with the built-in dotenv support? Unfortunately, it does not allow for custom paths - the dotenv file must live in the root directory of the project.

As noted in #38 (comment),

Variable references in the serverless instance are not resolved before a Plugin's constructor is called, so if you need these, make sure to wait to access those from your hooks.
~https://www.serverless.com/framework/docs/providers/aws/guide/plugins/#plugins/

. We do everything in the constructor today to try to be the first thing that happens when Serverless does its thing. However, that means. Serverless hasn't interpolated the values for us at that time.

There might be a way to trigger interpolation, but it might be via a non-public API, which isn't a great option.

Unfortunately, I do not have a workaround at time. Open to ideas!

I thought about this more, and I think there are sufficient alternatives that I am comfortable closing this with wontfix. I added some workarounds in #106.

Please feel free to reopen if you have additional feedback. Thanks!