Coder Social home page Coder Social logo

aschmidt75 / go-secretshelper Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 164 KB

CLI for accessing cloud-based vaults and secrets managers (Azure, AWS, GCP) in a uniform, declarative way.

License: MIT License

Makefile 1.05% Go 96.68% Shell 2.27%
golang azure keyvault aws secrets-manager gcp go

go-secretshelper's Introduction

go-secretshelper

go-secretshelper is both a library and a CLI to access secrets stored in vaults such as Cloud-based secrets managers, transform them and store them in files.

Go

Usage

go-secretshelper expects a yaml-based configuration file, which it processes. The configuration contains four major elements:

  • Vaults specify, where secrets are stored. Examples are Azure Key Vault or AWS Secrets Manager
  • Secrets define, what data is read from which vault.
  • Transformation describe,how secrets are modified, e.g. to decode base64 or render a template
  • Sinks specify where and how secrets are written. At present, only files are supported as sinks.

To run a configuration, use:

$ go-secretshelper run -c <config file>

Sample configuration file:

vaults:
  - name: myvault
    type: aws-secretsmanager
    spec:
      region: us-east-2

secrets:
  - type: secret
    vault: myvault
    name: sample

transformations:
  - type: template
    in:
      - sample
    out: sample-ini
    spec:
      template: |
        thesecret={{ .sample }}

sinks:
  - type: file
    var: sample-ini
    spec:
      path: ./sample.ini
      mode: 400

The above configuration defines a secret named sample, which is read from the AWS Secrets Manager instance in us-east-2. The secret is then transformed by the template and stored in a new secret named sample-ini. The new secret is written to a file named ./sample.ini with file mode 400. Such a configuration may define multiple vaults, secrets, multiple transformations and sinks.

See docs/ for more details. A configuration file may contain environment variables, which are expanded before processing by using the -e switch, e.g.:

secrets:
  - type: secret
    vault: ${VAULT_NAME}
    name: sample

This will expand the vault name of the environment variable VAULT_NAME and continue. This makes it possible to use the same configuration file for multiple environments.

Building

The Makefile's build target builds an executable in dist/.

$ make build 

To build exectuables for several platforms, the release target uses goreleaser:

$ make release

Testing

Unit tests

$ go test -v ./...

CLI tests

CLI tests are shell-based and written using bats. The executable is expected to be present in dist/. so make build is necessary before. To run the tests:

$ cd tests
$ bats .

Contributing

Pull requests are welcome!

License

(C) 2021 @aschmidt75, MIT License

go-secretshelper's People

Contributors

aschmidt75 avatar

Watchers

 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.