Make alert_before_expiry configurable - #101
Merged
onno-vos-dev merged 1 commit intoAug 5, 2026
Merged
Conversation
The 5-minute refresh buffer before token expiration was hardcoded, forcing callers with long-running operations (e.g. a file transfer exceeding 5 minutes) to force a fresh credential fetch beforehand rather than relying on the automatic background refresh. Expose it via the alert_before_expiry application environment variable so callers can widen the buffer to cover their own operation's duration.
Member
|
Hi there, sounds reasonable to me! I'll review tonight and roll out a release of it looks good 👍 Starting the pipeline at least now so you get feedback in case it fails 👍 |
onno-vos-dev
approved these changes
Aug 5, 2026
Member
|
@ethunk Tagged and released as 1.1.1: https://hex.pm/packages/aws_credentials/1.1.1 Thank you for your contribution 🙇 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The library refreshes credentials 5 minutes before expiry, and that window is hardcoded (
?ALERT_BEFORE_EXPIRY, 300).I'm using this library to retrieve a token used for a long-running file transfer. The transfer can take longer than 5 minutes, so the token can expire mid-transfer. Rather than forcing a fresh token fetch before every transfer job, I'd like to be able to widen the refresh window so I can guarantee no token is ever within X minutes of expiring — enough to cover the transfer's duration.
Change
Exposes the refresh window via the
alert_before_expiryapplication environment variable (in seconds), defaulting to the existing 300 (5 minutes) if unset:{aws_credentials, [{alert_before_expiry, 600}]}.Testing
configgroup inaws_credentials_SUITE) that setsalert_before_expiryto 60, mocks the EC2 provider with a known expiry, and asserts the scheduled refresh timer fires atexpiry - 60s.end_per_testcasenever unloaded theaws_credentials_filemeck, which corruptedaws_credentials_providers_SUITEwhen run in the same VM as the new test.rebar3 compile,lint,eunit,ct,dialyzer, andxrefall pass.