Skip to content

Instantly share code, notes, and snippets.

@yuji314159
Created July 11, 2018 16:06
Show Gist options
  • Save yuji314159/8342d35561b1aa2aa35832df562ed05d to your computer and use it in GitHub Desktop.
Save yuji314159/8342d35561b1aa2aa35832df562ed05d to your computer and use it in GitHub Desktop.
import gzip
import json
import boto3
def lambda_handler(event, context):
bucket_name = event['Records'][0]['s3']['bucket']['name']
object_key = event['Records'][0]['s3']['object']['key']
s3 = boto3.client('s3')
res = s3.get_object(Bucket=bucket_name, Key=object_key)
log = json.loads(gzip.decompress(res['Body'].read()).decode('utf-8'))
print(json.dumps(log, indent=2))
return log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment