Giter VIP home page Giter VIP logo

gcp-secret-manager-buddy's Introduction

GCP Secret Manager Buddy (gsm-buddy)

gsm-buddy can be used to fetch secrets from GCP Secret Manager as a group which is not currently supported by GCP Secret Manager.

Use Case

  • Fetch secrets for an app prior to it's deployment
  • Run gsm-buddy as a sidecar of an application to feed secrets periodically

Installation

Linux/macOS

curl -sSL https://github.com/yamaszone/gcp-secret-manager-buddy/releases/download/v0.1.2/gcp-secret-manager-buddy-v0.1.2-$(
    bash -c '[[ $OSTYPE == darwin* ]] && echo darwin || echo linux'
  )-amd64 -o gsm-buddy && chmod a+x gsm-buddy && sudo mv gsm-buddy /usr/local/bin/

Windows

Download executable from releases page

GCP Service Account Setup

project_id=my-gcp-project-id
sa_name=secrets-manager-reader-foo
iam_account="${sa_name}@${project_id}.iam.gserviceaccount.com"
gcloud iam service-accounts create "$sa_name" --display-name "$sa_name"
gcloud projects add-iam-policy-binding "$project_id" --member "serviceAccount:${iam_account}" --role "roles/secretmanager.viewer"
gcloud projects add-iam-policy-binding "$project_id" --member "serviceAccount:${iam_account}" --role "roles/secretmanager.secretAccessor"
gcloud iam service-accounts keys create --iam-account "$iam_account" ~/${sa_name}-key.json
export GOOGLE_APPLICATION_CREDENTIALS=~/${sa_name}-key.json

Usage

Prerequisites

Fetch Secrets from GCP Secret Manager

Input

cat input.json

{
	"KEY1":"gsm-secret-ID1",
	"KEY2":"gsm-secret-ID2"
}

Execute

gsm-buddy get -i input.json -p my-gcp-project

Output

{
	"KEY1":"secret-value1",
	"KEY2":"secret-value2"
}

Run as a Stub/Mock

gsm-buddy can be run as a stub by setting export GSM_IS_STUB=yes. This will bypass GCP Secret Manager communication and will simply output the content of the input file. This is useful for the following scenarios:

  • iterate on the gsm-buddy itself stubbing out the GCP Secret Manager
  • allow gsm-buddy to work for situations where GCP Secret Manager is unreachable

Input

cat input.json

{
	"KEY1":"secret-value1",
	"KEY2":"secret-value2"
}

Execute

gsm-buddy get -i input.json -p my-gcp-project

Output

{
	"KEY1":"secret-value1",
	"KEY2":"secret-value2"
}

Benchmark

Setup

  • gsm-buddy: gsm-buddy get -i secret-ids-sample.json -p tntprod
  • gcloud: for i in $(gcloud secrets list --format="value(name)" --filter=""); do echo $i=$(gcloud secrets versions access latest --secret $i); done

Result

Tool Time Operation
gsm-buddy (0.835s+1.105s+0.866s)/3=0.935s Average of 3 reads
gcloud (4.887s+5.123s+4.853s)/3=4.954s Average of 3 reads

NOTE: gcloud secret fetch method runs serially while gsm-buddy parallelize the fetch request. The secret fetch time will increase linearly for gcloud. For example, gcloud can take ~50s while gsm-buddy can take ~1s to fetch 10 secrets.

gcp-secret-manager-buddy's People

Contributors

yamaszone avatar

Watchers

 avatar

Forkers

altiscope

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.