Created
September 1, 2017 12:55
-
-
Save joshdvir/9e80adcdb4920964aa3f4b3c194cf02f to your computer and use it in GitHub Desktop.
Get a value from Vault
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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