Created
October 29, 2019 00:48
-
-
Save 2XXE-SRA/c9e4edfa6e92cf21a6899576012ab4b0 to your computer and use it in GitHub Desktop.
Get S3 bucket region anonymously via boto3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from botocore import UNSIGNED | |
from botocore.client import Config | |
s3 = boto3.client('s3', config=Config(signature_version=UNSIGNED)) | |
s3.head_bucket(Bucket="bucketname") | |
print(s3.head_bucket(Bucket="flaws.cloud")["ResponseMetadata"]["HTTPHeaders"]["x-amz-bucket-region"]) # output: us-west-2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment