This is a quick example to show how Vault's Database secrets work. Docker-compose spins up three containers:
- Vault
- PostgreSQL
- Configure
- Service
The test can be spun up by running:
docker-compose up --build
-
The Configure container first runs a script that configures Vault's Database Secrets backend and creates the necessary Role (imaginatively-named
my-role
). -
Then, the Service container requests new secrets for this Role. These secrets come with a 60s lease.
-
The 'service' then runs a loop that tests the DB connection and renews the secret lease every 30 seconds.
-
This continues until the secret reaches the
max_ttl
, which is set to 4 minutes in this example. At this point, Vault revokes the secret, and the connection will fail. A warning will be returned when attempting to renew a lease that would go beyond themax_ttl
.
- You can connect to the Vault UI at http://localhost:8200 (if the Docker networking Gods allow)
- You can login with the root token
abcd
- You can login with the root token