MCPcopy Create free account
hub / github.com/decodableco/examples / lambda_handler

Function lambda_handler

s3events/lambda.py:13–33  ·  view source on GitHub ↗
(event, context)

Source from the content-addressed store, hash-verified

11
12
13def lambda_handler(event, context):
14
15 # Get the object from the event and show its content type
16 for record in event['Records']:
17 bucket = record['s3']['bucket']['name']
18 key = urllib.parse.unquote_plus(record['s3']['object']['key'], encoding='utf-8')
19 try:
20 response = s3.get_object(Bucket=bucket, Key=key)
21 body = response['Body'].read()
22 for record in body.decode('utf-8').split('\n')[:-1]:
23 kinesis.put_record(
24 StreamName='s3-kinesis',
25 Data=record,
26 PartitionKey="-1")
27
28 return "success"
29
30 except Exception as e:
31 print(e)
32 print('Error getting object {} from bucket {}. Make sure they exist and your bucket is in the same region as this function.'.format(key, bucket))
33 raise e

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected