Python Boto3 auto-refresh credentials when assuming role

0

I've used the fromTemporaryCredentials before for Javascript, this automatically refreshes temp credential when assuming a role.

For boto3 for python however, we are unable to find this option. Is there a way to autiatically refresh 1 hour credentials when using boto3 when providing secret and key ? I see no good documentation on RefreshableCredentials but my list bucket operation just gets stuck forever when I try to use a sample here :

https://pritul95.github.io/blogs/boto3/2020/08/01/refreshable-boto3-session/
https://dev.to/li_chastina/auto-refresh-aws-tokens-using-iam-role-and-boto3-2cjf .
https://gist.github.com/kapilt/ac8e222081f63ba64e93

1 Answer
0

Based on the links that you have provided, it seems you have already done quite a good research on this topic and there are so many ways of doing this, but as you are looking for a readymade solution, I came across this sample code, which I tested and worked fine.

Please note that, you may need to tweak it further based on additional requirement as I couldn't find anything on AWS SDK sample for python.

Hope you find this useful.

Abhishek

profile pictureAWS
EXPERT
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions