【发布时间】:2020-10-10 11:16:51
【问题描述】:
我正在尝试处理来自 API 网关 -> Lambda -> API 网关交换的响应,但无法正确处理集成响应。
我有 2 个使用以下 Lambda 错误正则表达式定义的 API Gateway 集成响应:
.*e.* -> method response status 200 (for testing only)
.*500.* -> method response status 500
(no default mapping)
我的 Lambda 返回以下内容:
if (err)
callback(null, {
statusCode: 500,
message: "commit ID failed - ID already present"
});
else
callback(null, {
statusCode: 200,
message: "new ID committed"
});
因此,来自 Lambda 的响应中应该始终包含一些数据。
当我运行 API Gateway 测试时,它未能达到任何一条规则:
Sat Jun 20 07:49:56 UTC 2020 : Received response. Status: 200, Integration latency: 122 ms
Sat Jun 20 07:49:56 UTC 2020 : Endpoint response headers: {Date=Sat, 20 Jun 2020 07:49:56 GMT, Content-Type=application/json, Content-Length=68, Connection=keep-alive, x-amzn-RequestId=d7556a95-2ff9-4cf2-9e61-cc89484f6548, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=1-5eedbfa4-0ddb3f5e0882fbf1cd7e4674;sampled=0}
Sat Jun 20 07:49:56 UTC 2020 : Endpoint response body before transformations: {"statusCode":500,"message":"commit ID failed - ID already present"}
Sat Jun 20 07:49:56 UTC 2020 : Execution failed due to configuration error: No match for output mapping and no default output mapping configured. Endpoint Response Status Code: 200
如果我更改 Lambda 错误正则表达式:
.* matches responses from lambda
.+ doesn't match any responses from lambda
所以我认为这表明传递给 Lambda 错误正则表达式处理的任何字段都是空的 - 我是否正确,如果正确,如何在 Lambda 响应中为其设置值?
提前致谢,
吉姆
【问题讨论】:
标签: aws-lambda aws-api-gateway