Connection timeout to sts.amazonaws.com: pecularity of AWS STS PrivateLink Integration Issue with Lambda & Boto3

I have a Python-based Lambda function in VPC with an VPC endpoint creates for Amazon STS. However I could not connect to STS with timeout error:

STS timeout error

I’d spent a lot of time trying to find a root cause and finally found an answer in documentation:

“After you create the VPC endpoint, you must use the matching regional endpoint to send your AWS STS requests.”

So the proper way to connect to AWS STS with Python Boto3 library is:

It seems that when naively using STS through Boto3 (Python AWS SDK) the Global STS is targeted when we need to use a regional endpoint which is what the STS VPCIE is connected to.

Good luck!

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com