【发布时间】:2018-10-13 14:25:30
【问题描述】:
我有一个用 Python 2.7 编写的 Lambda 函数,它是从 API Gateway 触发的,
我希望 API Gateway 在 Lambda 失败时返回 400 代码并且我不想使用 Lambda 代理,因此我正在尝试设置 API Gateway 集成响应。
当 Lambda 函数失败时,它会返回:
{
"stackTrace": [
[
"/var/task/lambda_function.py",
12,
"lambda_handler",
"raise Exception('failure')"
]
],
"errorType": "Exception",
"errorMessage": "failure"
}
.. 与 CLI 相同:
aws apigateway get-integration-response --rest-api-id bz47krygwa --resource-id 788q0w --http-method ANY --status-code 400 --region us-west-1
{
"statusCode": "400",
"selectionPattern": ".*\"failure\".*",
"responseTemplates": {
"application/json": "#set($inputRoot = $input.path('$.errorMessage'))\n$inputRoot"
}
}
请问有什么修复建议吗?
【问题讨论】:
标签: python aws-lambda aws-api-gateway