You need to pass the statusCode
after executing the Lambda function. If you don't pass it the API Gateway will trigger an error 502 Bad Gateway
by default.
message = {
'message': 'Execution started successfully!'
}
return {
'statusCode': 200,
'headers': {'Content-Type': 'application/json'},
'body': json.dumps(message)
}
EDIT: This sample is for Python. For node.js you just need to handle callback, the message is basically the same.
callback(null, {
statusCode: 200,
body: JSON.stringify(message),
headers: {'Content-Type': 'application/json'}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…