ConnectorTypeVAULT
class connector_types.connector_type_vault.ConnectorTypeVAULT
Interact with HashiCorp Vault
Currently, only the Key-Value engine is supported.
For the KV engine, version 2 secrets the secret_path needs to be prefixed with data/
Input Schema
-
hostType:
string -
engine_pathVault's engine path.
Type:
stringDefault:
kv -
secret_pathPath of the secret.
Type:
anyOfOptions: -
modeThe mode to operate in.
Type:
anyOfOptions: -
tokenThe access token to authenticate.
Type:
string -
cacertType:
anyOfOptions: -
allow_redirectsIf set to
Falsedo not follow redirects.Falseby default.Type:
boolean -
max_redirectsMaximum number of redirects to follow.
10by default.Type:
integerDefault:
10 -
total_timeoutTotal timeout for the request.
Type:
anyOfOptions: -
connect_timeoutA timeout for connecting to a peer.
Type:
anyOfOptions: -
read_timeoutA timeout for reading a portion of data from a peer.
Type:
anyOfOptions: -
pathDEPRECATED. Replaced by
secret_path. -
dataDEPRECATED. Replaced by
mode.data. -
versionDEPRECATED. Replaced by
mode.version. -
versionsDEPRECATED. Replaced by
mode.versions.
Output Schema
-
status_codeType:
integer -
resultData
Constants
ssl_context_inputs = ['check_hostname', 'client_cert', 'client_key', 'server_ca']Example
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
# create a secret
this.connect(
connector_type='VAULT',
host='https://my-vault-host:8200',
engine_path='kv',
secret_path='data/my-secret',
data={
'secret-key': 'secret-value',
},
token='my-vault-token',
)
# read a secret
secret_value = this.connect(
connector_type='VAULT',
host='https://my-vault-host:8200',
engine_path='kv',
secret_path='data/my-secret',
version=None, # read latest version
token='my-vault-token',
).get('output_value')['result']['data']['data']
assert secret_value == {'secret-key': 'secret-value'}
# destroy all versions of secret
this.connect(
connector_type='VAULT',
host='https://my-vault-host:8200',
engine_path='kv',
secret_path='my-secret',
mode='delete_metadata',
token='my-vault-token',
)
return this.success('all done')