I have built a Kinesis Firehose delivery stream that has a lambda function transformation. In that lambda function I loop through my records similar to here. My function works fine, however I have some extra logic that has a throws an error some data is not validated.
The error I get is that Firehose writes to the s3 bucket for the error folder fine, but it does not give me my custom error message only a message indicating that an error occurred within the function. I found this documentation regarding Data Transformation Failure Handling. However it does not tell me how to modify the output.
def lambda_handler(event, context):
output = []
try:
for record in event['records']:
payload = base64.b64decode(record['data']).decode('utf-8')
# some other validation logic here
output_record = {
'recordId': record['recordId'],
'result': 'Ok',
'data': base64.b64encode(payload.encode('utf-8')).decode('utf-8')
}
output.append(output_record)
except Exception as e:
raise e
return {'records': output}