I’d like to discuss how to manually load Elixir configuration files at runtime.
I want to load an elixir config file (something that looks like, for example,
config/config.exs) at runtime, and load that into the application configuration.
Ultimately, I want to write a
Config.Provider implementation which fetches the contents of a secret stored in AWS secrets manager. I’d like for those contents to be an Elixir script with
import Config at the top, followed by configuration defined the same way you would in a project’s
config/config.exs file. I then want to load that configuration into the current (running!) application’s configuration.
Questions & Discussion
- Let’s assume that I can load the secret configuration file from anywhere into a binary with an arbitrary
Config.Providerimplementation (ignore SecretsManager for now). How would I go about compiling it and loading it into the application configuration?
- What do you think of this approach to secret management, at least in theory?
- What (at least roughly) do you do for secret management in your Elixir and/or Phoenix applications?
Let’s consider an alternative
Config.Provider implementation: instead load a YAML file, parse it, and translate it into a keyword list to merge into the current config. In my eyes that has a few downsides that I dislike:
- Added dependency on a YAML parser
- Designing how that YAML is structured is not a trivial task
- It’s a roundabout way to get to what I ultimately want, which is just to load configuration from a remote location into the current node’s application configuration.
These are my thoughts. Let me know yours!