Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Audrey Hayes
Audrey Hayes

Posted on

     

🔐 Intro to managing secrets using Mozilla SOPS 🔐

It should go without saying that secrets, such as passwords and API keys, should never be committed to any repository hosting services such as Github or GitLab in plaintext.

But how to share secrets with your team and maintain version control?

The old classic: Vault

One solution is to provision aVault server, which has built-in access control and secrets management.

You can then write scripts to automatically fetch a project's secrets according to the current environment using Vault's API and know that a lot of the work to secure access to those secrets is being done for you.

 Potential drawbacks

However, the drawbacks to this approach are the additional overhead and cost to maintain Vault on a server (most likely on a Kubernetes cluster in the cloud).

For small organisations without a dedicated DevOps team, you also need to have at least one expert on hand to maintain and debug the vault in the event it goes down, or more likely is "sealed".

In fact, every time a node in the cluster is restarted by your cloud provider (which depending on your pricing options, can occur fairly regularly) it will automatically seal the vault and require someone to manually port-forward into the cluster to "unseal" it with the appropriate set of access keys.

Relying on a secrets management system that affects every project when something goes wrong is less than ideal.

SOPS for the win (with caveats 😉)

Mozilla SOPS (short for Secrets OPerationS) is a neat little tool for encrypting files in formats such as YAML, JSON and ENV.

For example, say you have a simple YAML file storing the following secret:

// values.yamlsuper: secret
Enter fullscreen modeExit fullscreen mode

You can encrypt this file by runningsops -e -i values.yaml, which will output something like this:

// values.yamlsuper: ENC[AES256_GCM,data:PGCefhm7,iv:mjtXDC2EDTbjDurf0qAOS/OaUqgZs9RHAH6cTwjkXvc=,tag:CRtNcAZhOdv7G1tYfBIIOA==,type:str]
Enter fullscreen modeExit fullscreen mode

You can now keepvalues.yaml in your code repository in a much more human readable format that works will with version control (and makes git diffs much easier to handle).

In order to decrypt this file, SOPS needs the correct keys.

It pairs well with all the major cloud provider key management services so you can still reap the benefits of controlling access to the required keys to decrypt the files.

You can then rotate keys and create key groups based on which environment you'd like to decrypt the file in.

Pretty hand right?

I've read that this approach does not scale up well, which might be a major drawback for larger teams or projects.

Let me know in the comments if you've worked with SOPS and what your experience with it has been, good or bad!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Full stack
  • Work
    Software Developer Trainer at Mayden Academy
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp