but the vault agent is only logging (using the same role id and secret id):
2019/11/20 09:39:14.961767 [WARN] vault.read(copda/static/static-creds/copda): failed to check if copda/static/static-creds/copda is KVv2, assume not: Error making API request.
URL: GET http://127.0.0.1:8200/v1/sys/internal/ui/mounts/copda/static/static-creds/copda
Code: 403. Errors:
* preflight capability check returned 403, please ensure client's policies grant access to path "copda/static/static-creds/copda/"
2019/11/20 09:39:14.963646 [WARN] vault.read(copda/dynamic/creds/readonly): failed to check if copda/dynamic/creds/readonly is KVv2, assume not: Error making API request.
I’m working on integrating HashiCorp Vault into our application using Vault Agent for authentication. The initial setup works well, where the application reads the Vault token from a file generated by Vault Agent and uses it to authenticate with the Vault server.
However, I’m concerned about handling scenarios where the token’s max TTL is reached, and a new token is generated by Vault Agent.
Currently, our application reads the token once during initialization and uses it for subsequent operations. If the token expires and a new one is generated, the application wouldn’t automatically know about the new token, which could lead to failed operations.
To address this, I am thinking to implement a file watcher that monitors the token file for changes. When a new token is generated, the watcher reloads the token and updates the Vault client. While this seems to work in theory, I want to ensure that we’re following best practices and not missing any important considerations.
Here are the specific questions I have:
Is monitoring the token file for changes and reloading the token dynamically the recommended approach for handling token renewal with Vault Agent?
Are there any potential pitfalls or edge cases I should be aware of when implementing this solution?
Are there more efficient or reliable methods to ensure the application always has access to a valid token, especially in high-availability or production environments?
I’d appreciate any feedback or suggestions on improving this implementation.
If your application is using the vault token, you can test to see when it will expire and start reading as its expiration approaches. This is also the behavior that Vault-Agent uses - depending on the auth method, it will start the renewal / regeneration process at 2/3 rd the TTL. This will also allow you to do a smooth transition as both token will be valid for a period of time.
Your edge case is if the token is revoked or expires and doe not get renewed ( if the secret ID expires or is also revoked. )