Giter VIP home page Giter VIP logo

azure-keyvault-env's Introduction

Azure KeyVault Env

Build Status

A tool that populates secrets stored in Azure Keyvault into environment variables. It can also write them out to files. An idea behind it is to have a simple way to securely store secrets and populate them in Docker containers on instances running in Azure.

It is inspired by remind101/ssm-env project and is heavily based on cosmincojocar/adal-go cmd.

Special thanks to @yanzay for his help and contribution.

Build

For running in docker should be built in below way:

export GOPATH=$(pwd)
export GOBIN=$GOPATH/bin
go get
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"'

Running

Secrets from Key Vault will be exported as env variables:

azure-keyvault-env -vaultName <vault name> \
    -tenantId <tenant ID> \
    -applicationId <application ID> \
    -certificatePath path/to/certificate \
    -servicePrefix <service prefix>

Will result an output as follows:

export SECRET="SecretValue"
  • Secret name from Azure Key Vault will be in upper-case
  • - will be replaced with _
  • Serice prefix will be cut
  • -file suffix will be cut

secret name in Key Vault limited to regex pattern: ^[0-9a-zA-Z-]+$

Configuration can also be made via env variables, prefixed with AKE_:

AKE_VAULTNAME=<vault name>
AKE_TENANTID=<tenant ID>
AKE_APPLICATIONID=<application ID>
AKE_CERTIFICATEPATH=path/to/certificate
AKE_SERVICEPREFIX=<service prefix>

servicePrefix is used to filter keys in Key Vaults for particular service (i.e. docker container)

Aforementioned ends up with:

eval $(azure-keyvault-env)

which populates env variables from Key Vault and overrides current env.

Writing secrets to files

SecretValue in this case is expected to be location of destination file and base64 encoded (base64| tr -d '\n') value separated by space Otherwise util will fail on a decode step.

Given secret service-secret-file in key vault with value

/path/to/secret U2VjcmV0VmFsdWUK

Output will be:

export SECRET=/path/to/secret

and SecretValue will be written to a /path/to/secret file

azure-keyvault-env's People

Contributors

runtheops avatar k1rk avatar

Watchers

James Cloos avatar Alex 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.