Reputation:
I have enabled cloudtrail logging in s3 bucket. I am trying to use python sdk in order to parse all the logs in s3 bucket in order to isolate the RunInstance event. I have started with something like this :
def lambda_handler(event, context):
s3 = boto3.resource('s3')
bucket = s3.Bucket('eservice-aws-logging')
S3KeyPrefix='AWSLogs/********/CloudTrail/us-east-1/',
for obj in bucket.objects.all():
Is there a method in Python I can use in order to parse the logs and capture RunInstance events?
Upvotes: 3
Views: 1268
Reputation: 18270
You can read the content with
for obj in bucket.objects.all():
if S3KeyPrefix in obj.key:
content = obj.get()['Body'].read()
Once you have the content, parse it for the required events.
Upvotes: 1