How do I list all s3 bucket names with versioning flag turned on?
I have 100's of s3 buckets. Some of the buckets are having versioning flag turned on. I want to list all those bucket names using boto3.
I have given my python code snippet below.
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)