I wrote a Python package for creating automatically refreshing credentials so that AWS sessions can persist without interruption.
I hope you find this helpful!