myrealname
myrealname

Reputation: 3

Trying to pass variable key into hvac write function

Apologies for the dumb question, but I'd like to write variables to vault dynamically. I can't figure out the syntax for it. Maybe it's not possible. I'm basically trying to get this to work:

vault_client.write('secret/foo/%s' path, '%s=%s' % (key, value)).

When trying to run this, I get this error: strconv.ParseInt: parsing "key=value": invalid syntax

hvac wants something like this:

vault_client.write('secret/foo/path', key="value")

Is there a way to do this in python?

Thanks!

Upvotes: 0

Views: 1574

Answers (1)

Wayne Foux
Wayne Foux

Reputation: 135

Create a dictionary first. Pass the dictionary as the **kwargs to the function.

For example:

secrets = {'a': 'foo', 'b': 'bar', 'c': 'baz'}
path = 'secret/path'

client.write(path, **secrets)

Upvotes: 2

Related Questions