DEV Community

Auto-refresh AWS Tokens Using IAM Role and boto3

Chastina Li 👩🏻‍💻 on October 18, 2018

The Curse of The Hour Session management in AWS is complicated, especially when authenticating with IAM roles. A common way to obtain AW...
Collapse
 
noelleleigh profile image
Noelle Leigh

For future visitors: RefreshableCredentials isn't documented, but can be found in the source code.

Collapse
 
knoha profile image
Kostiantyn Noha • Edited

@li_chastina Thanks fir the snippets!
But one question: in order to refresh credentials do we need to call autorefresh_session.client each time we use a client functions or its enough to always use db_client reference and credentials refreshed automatically?

Collapse
 
jinyeng profile image
jinyeng

When I use this sample and print session info, looks like its generating a new credentials on every resource request !

Collapse
 
mandheer profile image
Mandheer

This post made my day.

Collapse
 
jinyeng profile image
jinyeng

Thanks For this great article. I am trying to use this code for S3 bucket listing and upload. I have two issues. I see that when I try to list bucket, it seems to again refresh credentials every time.

Also when trying to list bucket contents, it just gets stuck foerver without a response.

Collapse
 
icharle7 profile image
cmartín

This really worked for me. You helped me a lot. Thank you Chastina!
I will post again if i find something interesting about this botocore class.

Collapse
 
reka193 profile image
reka193

Perfect, thank you!!

Collapse
 
aaalllex profile image
aaalllex

Very useful
Thanks for sharing

Collapse
 
mbadawi23 profile image
melkammar

Would you be able to share the full class code here?

Collapse
 
avinashdalvi_ profile image
Avinash Dalvi

Good one

Collapse
 
sarkisvarozian profile image
Sarkis Varozian

Nice find and great post!

Collapse
 
mnmmeng profile image
mnmmeng

This is great!

Collapse
 
tuongtranqng profile image
tuongtranqng

Thanks Chastina, this post saves me.