awswrangler.s3.get_bucket_region

awswrangler.s3.get_bucket_region(bucket: str, boto3_session: Optional[boto3.session.Session] = None) → str

Get bucket region name.

Parameters
  • bucket (str) – Bucket name.

  • boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.

Returns

Region code (e.g. ‘us-east-1’).

Return type

str

Examples

Using the default boto3 session

>>> import awswrangler as wr
>>> region = wr.s3.get_bucket_region('bucket-name')

Using a custom boto3 session

>>> import boto3
>>> import awswrangler as wr
>>> region = wr.s3.get_bucket_region('bucket-name', boto3_session=boto3.Session())