2019-06-10 17:41:55 +00:00
|
|
|
|
---
|
2020-01-18 00:18:09 +00:00
|
|
|
|
layout: docs
|
|
|
|
|
page_title: kv put - Command
|
2019-06-10 17:41:55 +00:00
|
|
|
|
description: |-
|
|
|
|
|
The "kv put" command writes the data to the given path in the K/V secrets
|
|
|
|
|
engine. The data can be of any type.
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# kv put
|
|
|
|
|
|
|
|
|
|
The `kv put` command writes the data to the given path in the K/V secrets
|
|
|
|
|
engine.
|
|
|
|
|
|
|
|
|
|
If working with K/V v2, this command creates a new version of a secret at the
|
|
|
|
|
specified location. If working with K/V v1, this command stores the given secret
|
|
|
|
|
at the specified location.
|
|
|
|
|
|
|
|
|
|
Regardless of the K/V version, if the value does not yet exist at the specified
|
|
|
|
|
path, the calling token must have an ACL policy granting the "create"
|
|
|
|
|
capability. If the value already exists, the calling token must have an ACL
|
|
|
|
|
policy granting the "update" capability.
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
Writes the data to the key "creds":
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2022-06-15 23:07:50 +00:00
|
|
|
|
$ vault kv put -mount=secret creds passcode=my-long-passcode
|
2019-06-10 17:41:55 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The data can also be consumed from a file on disk by prefixing with the "@"
|
|
|
|
|
symbol. For example:
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2022-06-15 23:07:50 +00:00
|
|
|
|
$ vault kv put -mount=secret foo @data.json
|
2019-06-10 17:41:55 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Or it can be read from stdin using the "-" symbol:
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2022-06-15 23:07:50 +00:00
|
|
|
|
$ echo "abcd1234" | vault kv put -mount=secret foo bar=-
|
2019-06-10 17:41:55 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
2020-01-22 20:05:41 +00:00
|
|
|
|
There are no flags beyond the [standard set of flags](/docs/commands)
|
2019-06-10 17:41:55 +00:00
|
|
|
|
included on all commands.
|
|
|
|
|
|
|
|
|
|
### Output Options
|
|
|
|
|
|
|
|
|
|
- `-field` `(string: "")` - Print only the field with the given name. Specifying
|
|
|
|
|
this option will take precedence over other formatting directives. The result
|
|
|
|
|
will not have a trailing newline making it ideal for piping to other
|
|
|
|
|
processes.
|
|
|
|
|
|
|
|
|
|
- `-format` `(string: "table")` - Print the output in the given format. Valid
|
|
|
|
|
formats are "table", "json", or "yaml". This can also be specified via the
|
|
|
|
|
`VAULT_FORMAT` environment variable.
|
|
|
|
|
|
|
|
|
|
### Command Options
|
|
|
|
|
|
|
|
|
|
- `-cas` `(int: 0)` - Specifies to use a Check-And-Set operation. If not set the
|
2022-06-08 23:51:08 +00:00
|
|
|
|
write will be allowed. In order for a write to be successful, `cas` must be set to
|
|
|
|
|
the current version of the secret. If set to 0 a write will only be allowed if
|
|
|
|
|
the key doesn’t exist as unset keys do not have any version information. Also
|
|
|
|
|
remember that soft deletes do not remove any underlying version data from storage.
|
|
|
|
|
In order to write to a soft deleted key, the cas parameter must match the key's
|
|
|
|
|
current version. The default is -1.
|
2022-06-15 23:07:50 +00:00
|
|
|
|
|
|
|
|
|
- `-mount` `(string: "")` - Specifies the path where the KV backend is mounted.
|
|
|
|
|
If specified, the next argument will be interpreted as the secret path. If
|
|
|
|
|
this flag is not specified, the next argument will be interpreted as the
|
|
|
|
|
combined mount path and secret path, with /data/ automatically inserted for
|
|
|
|
|
KV v2 secrets.
|