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

Error handling in periodic credential update #989

Open
ynishinaka opened this issue May 17, 2024 · 0 comments
Open

Error handling in periodic credential update #989

ynishinaka opened this issue May 17, 2024 · 0 comments

Comments

@ynishinaka
Copy link

ynishinaka commented May 17, 2024

The fromWebIdentity passes to fetchAuthInBackground the action that performs the AssumeRoleWithWebIdentity [1]. AssumeRoleWithWebIdentity may throw ServiceError (as exception Amazonka.Types.Error), not just HTTPException. However, fetchAuthInBackground catches and throws only HTTPException to the original thread by throwTo, leaving other exceptions to the default handler [2]. Thus, if a ServiceError is thrown, the temporary credential update will be interrupted without the original thread being aware of it.

So, I believe that fetchAuthInBackground should either re-throw other exceptions raised by the action to the original thread or have some error recovery method.


[1]

let getCredentials = do
token <- Text.readFile tokenFile
let assumeRoleWithWebIdentity =
STS.newAssumeRoleWithWebIdentity
roleArn
sessionName
token
resp <- runResourceT $ sendUnsigned env assumeRoleWithWebIdentity
pure $ resp ^. STS.assumeRoleWithWebIdentityResponse_credentials
-- As the credentials from STS are temporary, we start a thread that is able
-- to fetch new ones automatically on expiry.
keys <- liftIO $ fetchAuthInBackground getCredentials

[2] Because the RetrievalError constructor accepts an argument of type HTTPException, e must be of the same type:

env <- Exception.try ma
case env of
Left e -> Exception.throwTo p (RetrievalError e)

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