如何列出打开版本标志的所有s3存储桶名称?
我有100个s3水桶。一些桶正在打开版本标志。我想使用boto3列出所有这些桶名称。
我在下面给出了我的python代码片段。
import boto3
REGION = "us-east-1"
s3client = boto3.client('s3',region_name=REGION)
for bucket in s3client.list_buckets()['Buckets']:
bucket = bucket['Name']
response = s3client.get_bucket_versioning(Bucket=bucket)
if 'Status' in response and response['Status'] == 'Enabled':
print(bucket)
import boto3
ACCESS = "AKIAI4JYMHUIYKIFABCD"
SECRET = "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"
REGION = "us-east-1"
s3client = boto3.client('s3',aws_access_key_id=ACCESS,aws_secret_access_key=SECRET,region_name=REGION)
for bucket in s3client.list_buckets()['Buckets']:
bucket = bucket['Name']
response = s3client.get_bucket_versioning(Bucket=bucket)
if 'Status' in response and response['Status'] == 'Enabled':
print(bucket)