b3ross / dotenvi

A simple library for generating dotenv files
MIT License
17 stars 7 forks source link

undefined variable results in no variable #30

Closed ksteiny closed 6 years ago

ksteiny commented 6 years ago

if cred: or cft: variable doesn't exist, it fails. it would be nice if undefined printed a warning and then remove the variable from .env vs a failure

b3ross commented 6 years ago

Yep - this is intentional. If your variable is truly not required you can use the optional syntax.

  OPTIONAL_VARIABLE:  ## Optional variable syntax.  Undefined variables will otherwise cause failures
    value: ${env:SOME_POSSIBLY_UNDEFINED_VARIABLE}
    optional: true
ksteiny commented 6 years ago

but thats the thing. my variable is required. its not optional. But we have a chicken and an egg scenario with this variable IA_TYPEORM_HOST: ${cft:api-starter-infrastructure-stack.RDSEndpoint} on every application (the first time its deployed). I have to comment out this line (because that stack doesn't exist), deploy my infrastructure stack (through every environment manually), and then re-enable the variable

b3ross commented 6 years ago

The only way to inject CFT properly if it's tied to the stack you're running on is to deploy the CFT first and then run dotenvi.