Save random strings to the key/value v2 plugin
Use password policies to generate random strings and save the strings to your key/value v2 plugin.
Before you start
- **You must have
read
,create
, andupdate
permission for password policies. - You must have
create
andupdate
permission for yourkv
v2 plugin.
Step 1: Create a password policy file
Create an HCL file with a password policy with the desired randomization and generation rules.
For example, the following password policy requires a string 20 characters long that includes:
- at least one lowercase character
- at least one uppercase character
- at least one number
- at least two special characters
Step 2: Save the password policy
Use vault write
to save policies to the password policies endpoint
(sys/policies/password/<policy_name>
):
For example:
Step 3: Save a random string to kv
v2
Use vault read
and the generate
endpoint of the new password policy to
generate a new random string and write it to the kv
plugin with
vault kv put
:
For example:
Step 4: Verify the data in Vault
Use vault kv get
with the -field
flag to read
the randomized string from the relevant secret path:
For example: