Hello I have a list of buckets that I would like to verify if those buckets have mfa enabled or not using python script, but I don't have much knowledge in python. Can anyone please help me. The process is to check the buckets then print if mfa is enabled or else print it's disabled. Thankyou.
CodePudding user response:
import boto3
buckets = ['...']
s3 = boto3.client('s3')
for b in buckets:
resp = s3.get_bucket_versioning(Bucket=b)
if mfa:=resp.get('MFADelete'):
print(f"{b}: MFA delete is {mfa}")
else:
print(f"{b}: MFA delete is never configured")