[RFC] Add method to load_keys
See original GitHub issueProblem
Suppose we have a secret store that has layout like this:

I would like to have a method to list all the keys.
Solution I have tried following piece of code in Vault_loader.py as:
def load_keys(obj, path):
client = get_client(obj)
return client.list('/secret/metadata/{}'.format(path))
It uses /secret/metadata endpoint for Vault and returns the dict that also contains keys.
Sample output:
{'request_id': '<redacted>',
'lease_id': '',
'renewable': False,
'lease_duration': 0,
'data': {'keys': ['secret1', 'secret2', 'secret3']},
'wrap_info': None,
'warnings': None,
'auth': None}
I can then do
vault_loader.load_keys(settings, 'sample/')['data']['keys']
['secret1', 'secret2', 'secret3']
Describe alternatives you’ve considered
IMHO, It only fits to use this solution because we have number of different credentials we want to store and retrieve. Another solution would be to dump all credentials under one secret in JSON format like this

The problem with that is if we have a lot of credentials(keys) in one secret(or environment) then updating one key would mean that I have to load entire data and then update relevant key and write the entire data again.
Additional context You may contact me on Google Chat/email(Red Hat) if you want to discuss our use case. I am fairly new to Vault/Dynaconf, excuse if my understanding is different that how this all is intended to be used.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)

Top Related StackOverflow Question
Hi @VaultVulp @kedark3 I understood that the goal is just o have a helper function to list all the
envsexisting on the vault server before one can iterate over it and usesetenvotusing_envto switch to them.I’ll make my suggestiong on the PR #214
Thanks @rochacbruno