Skip to content

Instantly share code, notes, and snippets.

@joshdvir
Created September 1, 2017 12:55
Show Gist options
  • Save joshdvir/9e80adcdb4920964aa3f4b3c194cf02f to your computer and use it in GitHub Desktop.
Save joshdvir/9e80adcdb4920964aa3f4b3c194cf02f to your computer and use it in GitHub Desktop.
Get a value from Vault
import sys
import hvac
import os
if(len(sys.argv) > 2 or len(sys.argv) == 1):
print("Error only key should be an argument")
quit()
var = sys.argv[1]
vault_client = hvac.Client(url=os.environ['VAULT_HOST'])
vault_client.auth_userpass(os.environ['VAULT_USERNAME'], os.environ['VAULT_PASSWORD'])
data = vault_client.read('secret/'+os.environ['VAULT_KEY'])['data']
for key, value in data.items():
if(key == var):
print value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment