Python Boto3 auto-refresh credentials when assuming role


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 : .

1 Answer

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.


profile pictureAWS
answered a year 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