Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in AWS by (12.9k points)

Problem:

I'm trying to get the region of the authenticated user from boto3.

Use case:

I'm working on adding cache to https://github.com/pmazurek/aws-fuzzy-finder. I would prefer to cache the result on per-region basis.

This package uses boto to get user authentication data (keys and the region). The problem is the region is never passed explicitly by the user, its being taken from one of the many murky places that boto reads so I don't really have a way of getting it.

I have tried searching through boto3 api and googling, but couldn't find anything like a get_region or get_user_data method. Is it possible?

1 Answer

0 votes
by (18.2k points)

You can read the region name using session.Session object as shown below:

my_session = boto3.session.Session()

my_region = my_session.region_name

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...