in detection-ml-wksp/aws_lambda/cloudtrail_ingest.py [0:0]
def get_workshop_log_files(s3_client, bucket, prefix=None):
"""
Loads the list of CloudTrail log files used for the Detection ML workshop
that are stored in an S3 bucket.
:param s3_client: Boto3 S3 client
:param bucket: name of the bucket from which to load log files
:param prefix: prefix within the bucket to search for log files
:return: tuple of bucket and key name
"""
res = s3_client.list_objects_v2(
Bucket=bucket,
Prefix=prefix,
)
for obj in res['Contents']:
if obj['Size'] > 0 and obj['Key'].endswith('gz'):
key = obj['Key']
yield bucket, key