2015-04-14 00:56:59 +00:00
|
|
|
---
|
|
|
|
layout: "docs"
|
2017-09-20 20:05:00 +00:00
|
|
|
page_title: "KV - Secrets Engines"
|
2017-09-15 13:02:29 +00:00
|
|
|
sidebar_current: "docs-secrets-kv"
|
2015-04-14 00:56:59 +00:00
|
|
|
description: |-
|
2017-09-20 20:05:00 +00:00
|
|
|
The KV secrets engine can store arbitrary secrets.
|
2015-04-14 00:56:59 +00:00
|
|
|
---
|
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
# KV Secrets Engine
|
2015-04-14 00:56:59 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
The `kv` secrets engine is used to store arbitrary secrets within the
|
|
|
|
configured physical storage for Vault.
|
2015-04-14 00:56:59 +00:00
|
|
|
|
2018-01-03 19:02:31 +00:00
|
|
|
Writing to a key in the `kv` backend will replace the old value; sub-fields are
|
|
|
|
not merged together.
|
2015-04-14 00:56:59 +00:00
|
|
|
|
2018-01-03 19:02:31 +00:00
|
|
|
Key names must always be strings. If you write non-string values directly via
|
|
|
|
the CLI, they will be converted into strings. However, you can preserve
|
|
|
|
non-string values by writing the key/value pairs to Vault from a JSON file or
|
|
|
|
using the HTTP API.
|
2015-04-14 00:56:59 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
This secrets engine honors the distinction between the `create` and `update`
|
2016-01-07 20:10:05 +00:00
|
|
|
capabilities inside ACL policies.
|
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
~> **Note**: Path and key names are _not_ obfuscated or encrypted; only the
|
|
|
|
values set on keys are. You should not store sensitive information as part of a
|
2015-10-29 15:21:40 +00:00
|
|
|
secret's path.
|
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
## Setup
|
2015-04-14 00:56:59 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
Most secrets engines must be configured in advance before they can perform their
|
|
|
|
functions. These steps are usually completed by an operator or configuration
|
|
|
|
management tool.
|
2016-06-09 00:14:36 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
The `kv` secrets engine is enabled by default at the path `secret/`. It can
|
|
|
|
be disabled, moved, or enabled multiple times at different paths. Each instance
|
|
|
|
of the KV secrets engine is isolated and unique.
|
2015-08-20 23:41:25 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
## Usage
|
2017-05-09 13:56:09 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
After the secrets engine is configured and a user/machine has a Vault token with
|
|
|
|
the proper permission, it can generate credentials. The `kv` secrets engine
|
|
|
|
allows for writing keys with arbitrary values.
|
2015-04-27 02:14:41 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
1. Write arbitrary data:
|
2015-04-27 02:14:41 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
```text
|
|
|
|
$ vault write secret/my-secret my-value=s3cr3t
|
|
|
|
Success! Data written to: secret/my-secret
|
|
|
|
```
|
2015-04-27 02:14:41 +00:00
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
1. Read arbitrary data:
|
|
|
|
|
|
|
|
```text
|
|
|
|
$ vault read secret/my-secret
|
|
|
|
Key Value
|
|
|
|
--- -----
|
|
|
|
refresh_interval 768h
|
|
|
|
my-value s3cr3t
|
|
|
|
```
|
|
|
|
|
|
|
|
## TTLs
|
|
|
|
|
|
|
|
Unlike other secrets engines, the KV secrets engine does not enforce TTLs
|
|
|
|
for expiration. Instead, the `lease_duration` is a hint for how often consumers
|
|
|
|
should check back for a new value. This is commonly displayed as
|
|
|
|
`refresh_interval` instead of `lease_duration` to clarify this in output.
|
|
|
|
|
|
|
|
If provided a key of `ttl`, the KV secrets engine will utilize this value
|
|
|
|
as the lease duration:
|
|
|
|
|
|
|
|
```text
|
|
|
|
$ vault write secret/my-secret ttl=30m my-value=s3cr3t
|
|
|
|
Success! Data written to: secret/my-secret
|
2015-04-27 02:14:41 +00:00
|
|
|
```
|
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
Even will a `ttl` set, the secrets engine _never_ removes data on its own. The
|
|
|
|
`ttl` key is merely advisory.
|
|
|
|
|
|
|
|
When reading a value with a `ttl`, both the `ttl` key _and_ the refresh interval
|
|
|
|
will reflect the value:
|
|
|
|
|
|
|
|
```text
|
|
|
|
$ vault read secret/my-secret
|
|
|
|
Key Value
|
|
|
|
--- -----
|
|
|
|
refresh_interval 30m
|
|
|
|
my-value s3cr3t
|
|
|
|
ttl 30m
|
|
|
|
```
|
2015-09-21 15:22:48 +00:00
|
|
|
|
|
|
|
## API
|
|
|
|
|
2017-09-20 20:05:00 +00:00
|
|
|
The KV secrets engine has a full HTTP API. Please see the
|
|
|
|
[KV secrets engine API](/api/secret/kv/index.html) for more
|
2017-03-09 02:47:35 +00:00
|
|
|
details.
|