Giter VIP home page Giter VIP logo

alamose-workshop-sandbox's Introduction

alamose-workshop-sandbox

First import necessary libraries

from http import client

from itertools import count

from venv import create

import hvac

import random

This function will create the connection with the vault.

def makeConnection():

hvc_client = hvac.Client(url='asfdasdf', token='asdfasdf' )

return hvc_client

This fuction will save or store secreate data to the vault

def storeSecret(client, secr1, cnt):

secret_path = 'SECRET_PATH_' + str(cnt)

create_response = client.secrets.kv.v2.create_or_update_secret(path='secret-path-1', secret=dict(password='Hashi123'))

This function will get or retrieve the data for secrtet from the vault.

def retrieveSecret(client_, cnt_):

secret_path = 'SECRET_PATH_' + str(cnt_)

read_response = client_.secrets.kv.read_secret_version(path='secret-path-1')

secret_from_vault = read_response['data']['data']['password']

print(secret_from_vault)

Main function to start the program

if name == 'main':

clientObject = makeConnection()

secretToStore = 'A_VERY_SPECIAL_SECRET'

counter = 0

print('The secret we want to store ', secretToStore)

print('='*50)

storeSecret(clientObject, secretToStore, counter)

print('=' * 50)

retrieveSecret(clientObject, counter)

print('=' * 50)

alamose-workshop-sandbox's People

Contributors

hongqin avatar

Watchers

 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.