HiveBrain v1.2.0
Get Started
← Back to all entries
patternbashMinor

Access vault secret from bash script

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
scriptbashvaultsecretfromaccess

Problem

I am looking for help on a direction on where to go from here. I have a Hasicorp Vault server running and accessible over DNS (local). I need to have a script get a secret from it then use that secret. I am not sure where to go from there. I know I want to use a bash script for this but past that I don't know what to do.

Until now I have been using curl to test it.

Suggestions?

Solution

The vault docs mention a -field parameter for the read subcommand. So you should be able to put this into a shell script:

SECRET=$(vault read -field foo secret/mysecret)


Other vault docs use the vault kv get in the same way so you might try:

SECRET=$(vault kv get -field foo secret/mysecret)

Code Snippets

SECRET=$(vault read -field foo secret/mysecret)
SECRET=$(vault kv get -field foo secret/mysecret)

Context

StackExchange DevOps Q#4503, answer score: 3

Revisions (0)

No revisions yet.