• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Vault
  • Install
  • Tutorials
  • Documentation
  • API
  • Try Cloud(opens in new tab)
  • Sign up
Vault Home

Documentation

Skip to main contentOverview
  • What is Vault?
  • Use Cases

  • Browser Support
  • Installing Vault

    • Overview
    • Active Directory
    • AliCloud
    • AWS
    • Azure
    • Consul
    • Cubbyhole
      • Overview
      • Cassandra
      • Couchbase
      • Elasticsearch
      • HanaDB
      • IBM Db2
      • InfluxDB
      • MongoDB
      • MongoDB Atlas
      • MSSQL
      • MySQL/MariaDB
      • Oracle
      • PostgreSQL
      • Redis
      • Redis ElastiCache
      • Redshift
      • Snowflake
      • Custom
    • Google Cloud
    • Google Cloud KMS
    • KMIP
      ENTERPRISEENTERPRISE
    • Kubernetes
    • MongoDB Atlas
    • Nomad
    • LDAP
    • RabbitMQ
    • Terraform Cloud
    • TOTP
    • Venafi (Certificates)
  • Vault Integration Program
  • Vault Interoperability Matrix
  • Troubleshoot






  • Glossary


  • Resources

  • Tutorial Library
  • Certifications
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Vault
  3. Documentation
  4. Secrets Engines
  5. Databases
  6. Redis
  • Vault
  • v1.11.x
  • v1.10.x
  • v1.9.x
  • v1.8.x
  • v1.7.x
  • v1.6.x
  • v1.5.x
  • v1.4.x

»Redis Database Secrets Engine

Redis is one of the supported plugins for the database secrets engine. This plugin generates database credentials dynamically based on configured roles for the Redis database.

See the database secrets engine docs for more information about setting up the database secrets engine.

Capabilities

Plugin NameRoot Credential RotationDynamic RolesStatic RolesUsername Customization
redis-database-pluginYesYesYesNo

Setup

  1. Enable the database secrets engine if it is not already enabled:

    $ 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.

  2. Configure Vault with the proper plugin and connection configuration:

    $ vault write database/config/my-redis-database \
      plugin_name="redis-database-plugin" \
      host="localhost" \
      port=6379 \
      tls=true \
      ca_cert="$CACERT"
      username="user" \
      password="pass" \
      allowed_roles="my-*-role"
    
  3. You should consider rotating the admin password. Note that if you do, the new password will never be made available through Vault, so you should create a Vault-specific database admin user for this.

    vault write -force database/rotate-root/my-redis-database
    

Usage

After the secrets engine is configured, write dynamic and static roles to Vault to enable generating credentials.

Dynamic roles

  1. Configure a dynamic role that maps a name in Vault to a JSON string containing the Redis ACL rules, which are either documented here or in the output of the ACL CAT Redis command.

    $ vault write database/roles/my-dynamic-role \
        db_name="my-redis-database" \
        creation_statements='["+@admin"]' \
        default_ttl="5m" \
        max_ttl="1h"
    Success! Data written to: database/roles/my-dynamic-role
    

    Note that if a creation_statement is not provided the user account will default to a read only user, '["~*", "+@read"]' that can read any key.

  2. Generate a new set of credentials by reading from the /creds endpoint with the name of the role:

    $ vault read database/creds/my-dynamic-role
    Key                Value
    ---                -----
    lease_id           database/creds/my-dynamic-role/OxCTXJcxQ2F4lReWPjbezSnA
    lease_duration     5m
    lease_renewable    true
    password           dACqHsav6-attdv1glGZ
    username           V_TOKEN_MY-DYNAMIC-ROLE_YASUQUF3GVVD0ZWTEMK4_1608481717
    

Static roles

  1. Configure a static role that maps a name in Vault to an existing Redis user.

    $ vault write database/static-roles/my-static-role \
        db_name="my-redis-database" \
        username="my-existing-redis-user" \
        rotation_period=5m
    Success! Data written to: database/static-roles/my-static-role
    
  2. Retrieve the credentials from the /static-creds endpoint:

    $ vault read database/static-creds/my-static-role
    Key                    Value
    ---                    -----
    last_vault_rotation    2020-12-20T10:39:49.647822-06:00
    password               ylKNgqa3NPVAioBf-0S5
    rotation_period        5m
    ttl                    4m39s
    username               my-existing-redis-user
    

API

The full list of configurable options can be seen in the Redis Database Plugin API page.

For more information on the database secrets engine's HTTP API please see the Database Secrets Engine API page.

Edit this page on GitHub

On this page

  1. Redis Database Secrets Engine
  2. Capabilities
  3. Setup
  4. Usage
  5. API
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)