/exvault

Elixir client library for Hashicorp Vault

Primary LanguageElixirBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

ExVault

Hex.pm package Build Status codecov Dependabot Status

Elixir client library for HashiCorp Vault.

Documentation is published on HexDocs.

Installation

The package can be installed by adding exvault to your list of dependencies in mix.exs:

def deps do
  [
    {:exvault, "~> 0.1.0-beta.1"},
  ]
end

You can also install the latest code from GitHub:

def deps do
  [
    {:exvault, github: "praekeltfoundation/exvault", sparse: "apps/exvault"},
  ]
end

Basic Usage

Start by creating a client with an API URL and an authentication token:

client = ExVault.new(address: "https://127.0.0.1:8200", token: "abcd-1234")

This client can then be used to make various API calls. Assuming a v1 key-value secret backend is mounted at /secret_kv_v1:

{:ok, _} = ExVault.write(client, "secret_kv_v1/my_key", %{"hello" => "world"})

{:ok, resp} = ExVault.read(client, "secret_kv_v1/my_key")
%{"hello" => "world"} = resp.logical.data

{:ok, _} = ExVault.delete(client, "secret_kv_v1/my_key")

{:ok, resp} = ExVault.read(client, "secret_kv_v1/my_key")
%ExVault.Response.Error{status: 404} = resp.logical.data