fix(auth): add RefreshingFileCredentialsProvider for credential rotation #24530
+412
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new
RefreshingFileCredentialsProviderthat periodically re-reads AWS credentials from file, solving the issue whereProfileFileCredentialsProvidercaches credentials indefinitely.Closes #18591
Problem
Vector's current file-based AWS authentication uses
ProfileFileCredentialsProviderwhich reads the credentials file once at startup and caches them indefinitely. This causesExpiredTokenerrors in long-running processes where credentials are rotated externally:Root Cause Analysis
ProfileFileCredentialsProvider caches indefinitely: The AWS SDK's
ProfileFileCredentialsProviderreads credentials once and doesn't re-read the file even when credentials expire.IdentityCache limitations: While
IdentityCache::lazy()supports automatic refresh, it relies on the underlying provider to return new credentials - whichProfileFileCredentialsProviderdoesn't do.SIGHUP doesn't help: Config reload via SIGHUP only recreates sinks if their config changed, not for credential refresh.
Solution
Introduce
RefreshingFileCredentialsProviderthat:RwLockfor concurrent accessNew Configuration Option
Changes
src/aws/refreshing_file_credentials.rsRefreshingFileCredentialsProviderimplementationsrc/aws/mod.rssrc/aws/auth.rsrefresh_interval_secsto File auth, use new providerTesting
ProviderStaterefresh logicrefresh_interval_secsconfig optionBackwards Compatibility
refresh_interval_secsoption is optional🤖 Generated with Claude Code