mbecker20 / komodo

🦎 a tool to build and deploy software on many servers 🦎
https://komo.do
GNU General Public License v3.0
1.83k stars 35 forks source link

Encrypt Secrets before syncing ressources #146

Closed Strehk closed 2 weeks ago

Strehk commented 2 weeks ago

I really like Komodo and the way to declaratively define resources via TOML with the whole git-sync-resource feature. We want to use Komodo for our non-profits docker environments, but one thing is currently holding me up: I feel very uneasy committing everything, including plain secrets, to a remote repository. Especially when I want to manage docker environments together with a team, the risk of me or co-workers accidentally spilling the secrets from the repository is currently too high for us to switch to komodo.

If there is already a solution for this problem, please let me know. Otherwise, here are suggestions on how to tackle this:

I would love a feature that allows all envs in the TOML to be encrypted by default – or that it can be activated per resource. In my imagination, the TOML would contain a flag that the env is encrypted and then the encrypted string which komodo can decrypt easily for each resource.

Another approach could be to manage all envs in a different TOML files and utilizing something like git-crypt to encrypt pre-push. That would also have the benefit of manually retrieving the key and therefore being able to decrypt the envs in local clones and therefore being able to fully edit the repository from a local clone.

A last approach could be to include a scripting/hooks feature to manually insert a git-crypt flow pre-push. But that would be quite tricky on my side I think.

mbecker20 commented 2 weeks ago

Yes, you should not commit secrets within the resource tomls. You can use Komodo's variables / secrets features:

First of all, a variable / secret is a key-value pair, where the key is non-secret.

KEY_1 = "value_1"

With this defined, you can interpolate the value into any Environment (and most other user configurable inputs) using the Komodo interpolation syntax:

environment = """
SOME_SECRET_ENV_VAR = [[KEY_1]] # <- wrap the key in double brackets '[[]]'
"""

So, how do you get these variables / secrets into Komodo?

Hopefully this helps to clarify things, secret management is always tough, let me know if you have any questions about this.

Strehk commented 2 weeks ago

Thanks a lot for this very thorough and helpful explanation! That is exactly what I needed.

Maybe I am just blind, but can that piece of information be found in the docs? If not, I think it would be helpful to provide just such an overview on how to manage Secrets? (I am happy to contribute if you'd like that – but I am not sure I am understanding everything good enough. I'd just take your answer as a blueprint.)

mbecker20 commented 2 weeks ago

Good point, I've added a page: https://komo.do/docs/variables