"errorMessage":"Invalid output structure: Please check your function and make sure the processed records contain valid result status of Dropped, Ok, or ProcessingFailed."
现在我创建了lambda函数,如下所示,以获得正确的输出结构:
import base64
import json
print('Loading function')
def lambda_handler(event, context):
output=[]
print('event'+str(event))
for record in event['records']:
payload = base64.b64decode(record['data'])
print('payload'+str(payload))
payload=base64.b64encode(payload)
output_record={
'recordId':record['recordId'],
'result': 'Ok',
'data': base64.b64encode(json.dumps('hello'))
}
output.append(output_record)
return { 'records': output }
现在我得到了以下关于将“数据”字段编码为
"errorMessage": "a bytes-like object is required, not 'str'",
如果我将“hello”更改为b“hello”之类的字节,则会出现以下错误:
"errorMessage": "Object of type bytes is not JSON serializable",