Create a working Vault server configuration given a scenario
Demo Database Secrets Engine
This guide explains how to configure HashiCorp Vault’s Database Secrets Engine for managing dynamic PostgreSQL credentials in AWS RDS.
In this guide, you’ll learn how to enable and configure HashiCorp Vault’s Database Secrets Engine to manage dynamic credentials for a PostgreSQL database running in AWS RDS. We’ll cover:
Start by listing all secrets engines currently enabled:
Copy
Ask AI
vault secrets list
Expected output:
Copy
Ask AI
Path Type Accessor Description---- ---- -------- -----------aws/ aws aws_9de29d31 n/acubbyhole/ cubbyhole cubbyhole_772dff42 per-token private secret storageidentity/ identity identity_8efc4dd9 identity storesys/ system system_5d807a2a system endpoints used for control, policy and debugging
A Vault “role” defines how dynamic users are created and what permissions they have:
Copy
Ask AI
vault write database/roles/hcvop-demo-role \ db_name="hcvop-db" \ default_ttl="4h" \ max_ttl="24h" \ creation_statements=" CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; GRANT SELECT ON ALL TABLES IN SCHEMA public TO \"{{name}}\"; "
db_name: Must match the configuration name (hcvop-db).
default_ttl/max_ttl: Time-to-live for generated credentials.
creation_statements: SQL executed to create a new user with permissions.
Verify the role:
Copy
Ask AI
vault read database/roles/hcvop-demo-role
Copy
Ask AI
Key Value--- -----creation_statements [CREATE ROLE "{{name}}" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; GRANT SELECT ON ALL TABLES IN SCHEMA public TO "{{name}}";]db_name hcvop-dbdefault_ttl 4hmax_ttl 24h