0

I am trying to iterate and retrieve the policies about all S3 buckets in an account.

I am trying the following...

s3 = boto3.client('s3')
buckets = s3.list_buckets()
for bucket_name in buckets['Buckets']:
    s3.get_bucket_policy(Bucket=bucket_name['Name'])

When I run this, I get the following error:

 botocore.exceptions.ClientError: An error occurred (PermanentRedirect) when calling the GetBucketTagging operation: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

I've tried used s3.meta.client.get_bucket_location(Bucket=bucket_name['Name']) as per https://github.com/boto/boto3/issues/81, but I get a value of None for 'LocationConstraint'.

How can I know or ascertain the correct endpoint and/or region for an arbitrary bucket?

4

1 回答 1

0

你做得对,减去一个花絮:值None表示美国标准区域[1],或us-east-1. 此外,您不需要使用元客户端。您已经创建的客户端具有该get_bucket_location方法。

于 2015-10-27T06:55:09.637 回答