Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vault secrets TTL values ignored and therefore rendering too often #1970

Open
EtienneBruines opened this issue Jul 29, 2024 · 0 comments
Open

Comments

@EtienneBruines
Copy link

Consul Template version

consul-template v0.39.1 (cc8f954)

Configuration

vault {
        address = "https://my-awesome-vault-server:8200"
        vault_agent_token_file = "/tmp/test-token"
        unwrap_token = false
        renew_token = false
}
template {
  destination = "/tmp/my-test-output"
  contents = <<EOH
{{- with secret "identity/oidc/token/my-test-role" -}}
{{ .Data | toJSON }}
{{ end }}
  EOH
}

This produces a file like this:

{"client_id":"my-test-id","token":"-my-secret-token-","ttl":86400}

Command

consul-template -config=my-config.hcl

Debug output

The relevant parts:

2024-07-29T13:45:34.451Z [DEBUG] (runner) diffing and updating dependencies
2024-07-29T13:45:34.451Z [DEBUG] (runner) watching 1 dependencies
2024-07-29T13:45:34.451Z [TRACE] (view) vault.read(identity/oidc/token/my-test-role) starting fetch
2024-07-29T13:50:09.120Z [TRACE] vault.read(identity/oidc/token/my-test-role): GET /v1/identity/oidc/token/my-test-role
2024-07-29T13:50:09.138Z [TRACE] vault.read(identity/oidc/token/my-test-role): non-renewable secret, set sleep for 4m25.295077421s

Expected behavior

What should have happened?

The token should not be renewed every 5 minutes, but respect the TTL of the token (at least somewhat). Anything after 50% of TTL sounds reasonable, but every 5 minutes for a 24h TTL is not desired.

Actual behavior

What actually happened?

The token refreshed after only 5 minutes.

Steps to reproduce

  1. Setup and configure a Vault server
  2. Generate a new identity key vault write --force identity/oidc/key/my-test-key
  3. Generate a new role that uses that key vault write identity/oidc/role/my-test-role key=my-test-key ttl=24h client_id=my-test-id template="{}"
  4. Now use consul-template to get a token for that (see config above).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant