Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rich JSON secrets #235

Open
stpierre opened this issue Aug 8, 2023 · 0 comments
Open

Support rich JSON secrets #235

stpierre opened this issue Aug 8, 2023 · 0 comments

Comments

@stpierre
Copy link

stpierre commented Aug 8, 2023

A pattern I've found useful in the past is to store multiple data as JSON within a single secret. For instance, if an integration requires a username and password, store both:

% gcloud secrets versions access 1 --secret=my-rich-secret
{"username":"stpierre","password":"hunter2"}

This:

  • Reduces storage and access costs (which are per-secret, not per-byte)
  • Allows atomic changes to complex data
  • Ensures that related data is stored together

Storing the username locally and only storing the password as a secret reduces cost, but it means that you can't guarantee that the username and password get changed atomically, and half of the credentials are stored in one place and the other half in another place. These concerns become heightened when working with integrations that require more than two credentials, or when using multiple independent sets of credentials for seamless password rotations.

To support this flow in berglas, currently (AIUI) you have to postprocess the environment variables that berglas populates, which isn't tenable with third-party container workloads. I would propose to add a path option to the sm:// reference syntax that accepts a JMESPath expression, so that in a ConfigMap you could do, for instance:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-cm
data:
  MY_USERNAME: "sm://my-proj-123456/my-rich-secret?path=username"
  MY_PASSWORD: "sm://my-proj-123456/my-rich-secret?path=password"

I'm happy to contribute the code for this feature, but wanted to first check to see if this feature would be accepted (or, better yet, if there's already a way to do this that I'm overlooking).

stpierre added a commit to stpierre/berglas that referenced this issue Aug 22, 2023
This permits a user to store JSON objects as GSM data, and query
specific items in those objects with a JMESPath expression.

Fixes GoogleCloudPlatform#235.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants