'How to verify if MFA delete is on or not on a list of bucket using Python script
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.
Solution 1:[1]
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")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jellycsc |
