Vaultex
A very simple read only client that authenticates and reads secrets from HashiCorop's Vault.
Installation
The package can be installed as:
-
Add vaultex to your list of dependencies in
mix.exs:
def deps do
[{:vaultex, "~> 0.0.1"}]
end- Ensure vaultex is started before your application:
def application do
[applications: [:vaultex]]
endConfiguration
In your config.exs file add:
config :vaultex, app_id: System.get_env("VAULT_APP_ID")
config :vaultex, user_id: System.get_env("VAULT_USER_ID")The vault endpoint can be specified with environment variables:
VAULT_HOSTVAULT_PORTVAULT_SCHEME
Or application variables:
:vaultex, :host:vaultex, :port:vaultex, :scheme
These default to localhost, 8200, http respectively.
Usage
The library requires to authenticate first with:
alias Vaultex.Client, as: Vault
...
Vault.auth #returns {:ok, :authenticated}After successful authentication, you can read a secret with:
...
Vault.read("secret/foo") #returns {:ok, "bar"}