DEV Community

Discussion on: How do you store private keys?

Collapse
 
dbanisimov profile image
Denis Anisimov

My projects are based on Google Cloud Platform and over the years I've used two different approaches:

  1. Encrypt .env files and store them in the git repo. Manage encryption keys via Cloud KMS. This approach has an advantage that secrets are stored with the code and it's easy to distribute them.
  2. Use Secret Manager to store arbitrary (.env, .json) configurations and pull those directly from google. This way it's easier to rotate the configurations and it provides audit logs for secrets access.
Collapse
 
timjohns profile image
Tim Johns

Denis - regarding #2, curious if you see advantages/disadvantages to storing complete configurations vs. individual distinct secrets?

Collapse
 
dbanisimov profile image
Denis Anisimov

If all the secrets are used together, then I'd store them together in one configuration. Unless there is some complex requirement for rotating individual keys - in this case having separate secrets makes managing their versions easier.