How to Create Refreshable Boto3 Session

Ritul Patel
1 min readAug 2, 2020

Purpose of this post is to show how to leverage botocore library to create refreshable boto3 session.

There are many good reason to use refreshable boto3 session. One common scenario is that in order to reduce https latency when creating boto3 connections, people might cache client or resource object. But if we don’t use refreshable boto3 session, we might run into issue where credentials might have expired and then any boto3 call will fail with expired token error.

Here’s how you can do that:

Enjoy Coding!!!

--

--

Ritul Patel

Software Engineer with passion to learn new tech!