Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active September 13, 2019 18:09
Show Gist options
  • Save diegopacheco/60fdb78c24fadbdf2f9dcabf2097f734 to your computer and use it in GitHub Desktop.
Save diegopacheco/60fdb78c24fadbdf2f9dcabf2097f734 to your computer and use it in GitHub Desktop.
Vault Cheat Sheet

Open vault-ui

xdg-open "http://localhost:8200/ui/"

Test Vault login via API

curl --silent -k -X GET -H "X-Vault-Token:00000000-0000-0000-0000-000000000000" 'http://127.0.0.1:8200/v1/auth/token/lookup-self'

Test Read Secret via API

curl --silent -k -X GET -H "X-Vault-Token:00000000-0000-0000-0000-000000000000" 'http://127.0.0.1:8200/v1/secret/data/test' | jq . 

Read K/V

export VAULT_ADDR='http://127.0.0.1:8200'
vault kv get secret/test

Read K/V in Json format

export VAULT_ADDR='http://127.0.0.1:8200'
vault kv get -format=json secret/test

Use JQ to get parts of the Json

export VAULT_ADDR='http://127.0.0.1:8200'
vault kv get -format=json simple_aws/dev | jq -r .data.data

Write values in KV store

vault kv put secret/test hello=world

Vault + Gradle

build.gradle

plugins {
  id "io.errorlab.gradle.vault" version "0.1.0"
}
vault { 
  addr = "http://localhost:8200"
  token = "00000000-0000-0000-0000-000000000000"
}
task testConf {
  doLast{
    println project.vault.get("secret/data/rds/dev").data.data["jdbc.url"]
    println project.vault.get("secret/data/rds/dev").data.data["user.pass"] 
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment