Skip to content

Instantly share code, notes, and snippets.

@stenio123
Created September 7, 2018 15:59
Show Gist options
  • Save stenio123/30c6a444576b7d4401c473a9ed4aeaa9 to your computer and use it in GitHub Desktop.
Save stenio123/30c6a444576b7d4401c473a9ed4aeaa9 to your computer and use it in GitHub Desktop.
Steps to deploy custom gem (Vault-ruby as example)
  1. Clone git repository:
git clone [email protected]:stenio123/vault-ruby.git
  1. Move to desired branch:
git checkout added-namespaces
  1. Create gem:
gem build vault.gemspec
  1. Install gem:
gem install ./vault-0.12.1.gem
  1. Create test code:
# test.rb
require 'vault'

vault_client = Vault::Client.new(address: ENV["VAULT_ADDR"], token: ENV["VAULT_ADDR"], namespace: ENV["VAULT_NAMESPACE"])

# Edit the secret path as needed
secret = Vault.logical.read("secret/app1")
puts secret.data
  1. Set environment variables accordingly:
export VAULT_ADDR=YOUR-VAULT-ADDRESS
# Note that the ruby gem can also look for the Vault token in ~/.vault-token if this env var is not set
export VAULT_TOKEN=YOUR-VAULT-TOKEN
export VAULT_NAMESPACE=YOUR-VAULT-NAMESPACE
  1. Run the test code:
ruby test.rb
# Output:
{:test=>"secret"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment