(event, context)
| 11 | |
| 12 | |
| 13 | def 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 |
nothing calls this directly
no outgoing calls
no test coverage detected