Skip to content

Commit e78db3f

Browse files
committed
Use AWS_SESSION_TOKEN if in the environment
Allows people to use the temporary tokens as described here: https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs
1 parent 9f2b58a commit e78db3f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Aws/Core.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,12 @@ loadCredentialsFromFile file key = liftIO $ do
309309
loadCredentialsFromEnv :: MonadIO io => io (Maybe Credentials)
310310
loadCredentialsFromEnv = liftIO $ do
311311
env <- getEnvironment
312-
let lk = flip lookup env
312+
let lk = fmap (T.encodeUtf8 . T.pack) . flip lookup env
313313
keyID = lk "AWS_ACCESS_KEY_ID"
314314
secret = lk "AWS_ACCESS_KEY_SECRET" `mplus` lk "AWS_SECRET_ACCESS_KEY"
315-
Traversable.sequence
316-
(makeCredentials <$> (T.encodeUtf8 . T.pack <$> keyID)
317-
<*> (T.encodeUtf8 . T.pack <$> secret))
315+
setSession creds = creds { iamToken = lk "AWS_SESSION_TOKEN" }
316+
makeCredentials' k s = setSession <$> makeCredentials k s
317+
Traversable.sequence $ makeCredentials' <$> keyID <*> secret
318318

319319
loadCredentialsFromInstanceMetadata :: MonadIO io => io (Maybe Credentials)
320320
loadCredentialsFromInstanceMetadata = liftIO $ HTTP.withManager $ \mgr ->

0 commit comments

Comments
 (0)