Coder Social home page Coder Social logo

bruecktech / secretsmanager-versioning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from taimos/secretsmanager-versioning

0.0 1.0 0.0 663 KB

Toolkit to version secrets in AWS SecretsManager

License: Apache License 2.0

JavaScript 13.66% TypeScript 86.34%

secretsmanager-versioning's Introduction

SecretsManger Versioning

A CLI Tool to manage and version AWS Secrets with SOPS

Overview

SecretsManager Version is a CLI Tool for Secrets in combination with SOPS. It helps you keep your secrets safe and versioned inside git projects. The SecretsManager is capable of storing up to 20 tagged secret versions which SecretsManger-Versioning will make use of. The secrets will be versioned by using the MD5 Hash of the encrypted file. With this, every change of the SOPS file will be tagged with a unique key to reference. On top of that, each tag is connected with a Git project and Commit Hash to trace its origin.

Prerequisites

Secret Management

Create a new git repository and open a new terminal there:

git init .
git remote add origin [email protected]:username/new_repo

Create a new sops file and encrypt it with your kms key:

sops --kms arn:aws:kms:region:account:key/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx sops.json

Now run the following to test if the configuration works:

npx secretsmanager-versioning -f sops.json SecretName

You should be able to verify that a secret under this name in the currently logged-in account and region was created for you. You can also create a secret yourself and simply reference it. You can verify this by checking the secret in your console or by executing:

aws secretsmanager describe-secret --secret-id SecretName

You should be able to verify that the secret is tagged with a md5 hash and the current version should reference your recent commit.

Usage

The secret can be used by referring to with the md5 hash. There are multiple ways to do this. One example is highlighted here.

Decrypted Sops File (sops.json)

{
  "example": "supersecretstring"
}

CDK

Add the md5-file dependency to your project and reference your sops file and Secret. After that you should be to reference a jsonField to get reference the secret value:

import { sync as md5 } from "md5-file";
const secretPath = "SecretName";
const versionId = md5("sops.json");
const secret = cdk.SecretValue.secretsManager(secretPath, {
  jsonField: "example",
  versionId: versionId,
}).toString();
console.log(secret); // {{resolve:secretsmanager:SecretName:SecretString:example::md5hashvalue}}

secretsmanager-versioning's People

Contributors

bruecktech avatar hoegertn avatar patrickdomnick 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.