Vault
Write custom metadata in key/value v2
Write custom metadata to a kv
v2 secret path for ???.
Assumptions
- You have set up a
kv
v2 plugin. - Your authentication token has
metadata
permissions for thekv
v2 plugin.
Use vault kv metadata put
to set custom
metadata fields for a kv
mount path. Repeat the -custom-metadata
flag for
each key/value metadata entry:
$ vault kv metadata put \
-custom-metadata <key_value_pair> \
-mount <mount_path> \
<secret_path>
For example:
$ vault kv metadata put \
-custom-metadata "desc=API keys for different dev environments" \
-custom-metadata "renew-date=2026-11-14" \
-mount shared \
dev/square-api
Success! Data written to: shared/metadata/dev/square-api
The custom_metadata
metadata field now includes a map with the two custom
fields:
$ vault kv metadata get -mount shared dev/square-api
======== Metadata Path ========
shared/metadata/dev/square-api
========== Metadata ==========
Key Value
--- -----
cas_required false
created_time 2024-11-13T21:51:50.898782695Z
current_version 9
custom_metadata map[desc:API keys for different dev environments renew-date:2026-11-14]
delete_version_after 0s
max_versions 10
oldest_version 4
updated_time 2024-11-15T03:10:26.749233814Z
====== Version 1 ======
Key Value
--- -----
created_time 2024-11-13T21:51:50.898782695Z
deletion_time n/a
destroyed false