Code Monkey home page Code Monkey logo

vault-app-examples's Introduction

vault-app-examples

An example vault client that reads KV2 **Note: this is an example client only and does not indicate best practices in reading secrets from Vault. Please do not use this app in production.

Vault setup

# Setup environment
export VAULT_ADDR="http://vault-gke:8200"
export VAULT_TOKEN="root-or-admin-token"

# Setup KV and policy
cd go-kv2/
vault secrets enable -path=kv2 -version=2 kv
vault kv put kv2/api_token API_TOKEN=v1.abcd
vault kv put kv2/api_token API_TOKEN=v2.efgh
vault kv put kv2/api_token API_TOKEN=v3.ijkl
vault policy write app1 app1-policy.hcl

Building and Running the App

export VAULT_TOKEN=$(vault token create -format=json -policy=app1 | jq -r .auth.client_token)
export SECRET_PATH=kv2/data/api_token
export SECRET_VERSION=2
export SECRET_KEY=API_TOKEN

go build -o vault-app .
./vault-app

Example output

3289488Z deletion_time: destroyed:false version:2]]
Warnings: %v []
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~ Printing  Data ~~~~~
map[API_TOKEN:v2.efgh]
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~ Printing value for Key: API_TOKEN ~~~~~
v2.efgh
~~~~~~~~~~~~~~~~~~~~~~~~~~
2020/02/06 01:19:09 Starting renewal loop
2020/02/06 01:19:09 secret is not renewable

vault-app-examples's People

Contributors

kawsark avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.