Skip to content

Instantly share code, notes, and snippets.

View benyitzhaki's full-sized avatar

Ben Yitzhaki benyitzhaki

View GitHub Profile
@benyitzhaki
benyitzhaki / Find Search Empty s3 buckets AWS Lambda (python 3.7)
Last active September 6, 2020 14:09
AWS Lambda to find all empty buckets in AWS S3 account
import json
import boto3
import array
s3 = boto3.resource('s3')
def lambda_handler(event, context):
empty_buckets = [];
for bucket in s3.buckets.all():
is_empty = [] == [i for i in bucket.objects.limit(1).all()]
{"lastUpload":"2019-07-31T13:46:45.430Z","extensionVersion":"v3.4.1"}