1

I have a Python app that uses boto3 to list & read objects from AWS S3 buckets:

session = boto3.session.Session(aws_access_key_id=XYZ, aws_secret_access_key=ABC)
client = session.resource('s3').meta.client
listing = client.list_objects(…)

The app works great except for buckets in the China region, where it blows up with The AWS Access Key Id you provided does not exist in our records (the access key & secret are correct).

I googled up something about providing special ARNs / URLs for AWS in China, here and here. But what do I do in practice, concretely?

If the bucket is in China, how do I initialize the boto3 client so that the rest of my code works as normal?

user124114
  • 8,372
  • 11
  • 41
  • 63
  • e.g. use boto3.client instead of a session and pass it a config with the region: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html ...or pass the region directly to the client like in this post: https://stackoverflow.com/a/40377889/12693728 – mrxra May 09 '23 at 09:40
  • 1
    e.g. it seems you can pass the region_name to the session too ( https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html) like this: boto3.session.Session(..., region_name="cn-north-1") – mrxra May 09 '23 at 09:44

0 Answers0