2019-01-09 01:26:16 +00:00
|
|
|
---
|
2020-01-18 00:18:09 +00:00
|
|
|
layout: docs
|
2020-05-01 21:05:05 +00:00
|
|
|
page_title: InfluxDB - Database - Secrets Engines
|
|
|
|
sidebar_title: InfluxDB
|
2019-01-09 01:26:16 +00:00
|
|
|
description: |-
|
2020-05-01 21:05:05 +00:00
|
|
|
InfluxDB is one of the supported plugins for the database secrets engine.
|
2019-01-09 01:26:16 +00:00
|
|
|
This plugin generates database credentials dynamically based on configured
|
2020-05-01 21:05:05 +00:00
|
|
|
roles for the InfluxDB database.
|
2019-01-09 01:26:16 +00:00
|
|
|
---
|
|
|
|
|
2020-05-01 21:05:05 +00:00
|
|
|
# InfluxDB Database Secrets Engine
|
2019-01-09 01:26:16 +00:00
|
|
|
|
2020-05-01 21:05:05 +00:00
|
|
|
InfluxDB is one of the supported plugins for the database secrets engine. This
|
2019-01-09 01:26:16 +00:00
|
|
|
plugin generates database credentials dynamically based on configured roles for
|
2020-05-01 21:05:05 +00:00
|
|
|
the InfluxDB database.
|
2019-01-09 01:26:16 +00:00
|
|
|
|
2020-01-22 20:05:41 +00:00
|
|
|
See the [database secrets engine](/docs/secrets/databases) docs for
|
2019-01-09 01:26:16 +00:00
|
|
|
more information about setting up the database secrets engine.
|
|
|
|
|
2020-05-01 21:05:05 +00:00
|
|
|
## Capabilities
|
|
|
|
| Plugin Name | Root Credential Rotation | Dynamic Roles | Static Roles |
|
|
|
|
| --- | --- | --- | --- |
|
|
|
|
| `influxdb-database-plugin` | Yes | Yes | No |
|
|
|
|
|
2019-01-09 01:26:16 +00:00
|
|
|
## Setup
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
1. Enable the database secrets engine if it is not already enabled:
|
2019-01-09 01:26:16 +00:00
|
|
|
|
|
|
|
```text
|
|
|
|
$ vault secrets enable database
|
|
|
|
Success! Enabled the database secrets engine at: database/
|
|
|
|
```
|
|
|
|
|
|
|
|
By default, the secrets engine will enable at the name of the engine. To
|
|
|
|
enable the secrets engine at a different path, use the `-path` argument.
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
1. Configure Vault with the proper plugin and connection information:
|
2019-01-09 01:26:16 +00:00
|
|
|
|
|
|
|
```text
|
|
|
|
$ vault write database/config/my-influxdb-database \
|
|
|
|
plugin_name="influxdb-database-plugin" \
|
|
|
|
host=127.0.0.1 \
|
2020-05-01 21:05:05 +00:00
|
|
|
username=vaultuser \
|
|
|
|
password=vaultpass \
|
2019-01-09 01:26:16 +00:00
|
|
|
allowed_roles=my-role
|
|
|
|
```
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
1. Configure a role that maps a name in Vault to an SQL statement to execute to
|
|
|
|
create the database credential:
|
2019-01-09 01:26:16 +00:00
|
|
|
|
|
|
|
```text
|
|
|
|
$ vault write database/roles/my-role \
|
|
|
|
db_name=my-influxdb-database \
|
2019-01-18 01:14:57 +00:00
|
|
|
creation_statements="CREATE USER \"{{username}}\" WITH PASSWORD '{{password}}'; \
|
2020-01-18 00:18:09 +00:00
|
|
|
GRANT ALL ON \"vault\" TO \"{{username}}\";" \
|
2019-01-09 01:26:16 +00:00
|
|
|
default_ttl="1h" \
|
|
|
|
max_ttl="24h"
|
|
|
|
Success! Data written to: database/roles/my-role
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
After the secrets engine is configured and a user/machine has a Vault token with
|
|
|
|
the proper permission, it can generate credentials.
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
1. Generate a new credential by reading from the `/creds` endpoint with the name
|
|
|
|
of the role:
|
2019-01-09 01:26:16 +00:00
|
|
|
|
|
|
|
```text
|
|
|
|
$ vault read database/creds/my-role
|
|
|
|
Key Value
|
|
|
|
--- -----
|
|
|
|
lease_id database/creds/my-role/2f6a614c-4aa2-7b19-24b9-ad944a8d4de6
|
|
|
|
lease_duration 1h
|
|
|
|
lease_renewable true
|
|
|
|
password 8cab931c-d62e-a73d-60d3-5ee85139cd66
|
2020-05-01 21:05:05 +00:00
|
|
|
username v-vaultuser-e2978cd0-
|
2019-01-09 01:26:16 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
2020-05-01 21:05:05 +00:00
|
|
|
The full list of configurable options can be seen in the [InfluxDB database
|
2020-01-22 20:05:41 +00:00
|
|
|
plugin API](/api/secret/databases/influxdb) page.
|
2019-01-09 01:26:16 +00:00
|
|
|
|
|
|
|
For more information on the database secrets engine's HTTP API please see the [Database secret
|
2020-01-22 20:05:41 +00:00
|
|
|
secrets engine API](/api/secret/databases) page.
|