aih*_*dad 1 amazon-web-services aws-cloudformation aws-lambda aws-api-gateway aws-cdk
默认 API 网关响应采用以下形式:{"message":$context.error.messageString}。通过控制台更改此模板,"error"例如将其包装在对象中,效果很好。但是,当我在 CDK 中尝试时,在部署过程中出现错误Invalid mapping expression specified
代码(注意这实际上是默认模板):
webServiceApi.addGatewayResponse('4XX', {
type: apigw.ResponseType.DEFAULT_4XX,
responseHeaders: COMMON_HEADERS,
templates: {
'application/json': '{"message":$context.error.messageString}',
},
});
Run Code Online (Sandbox Code Playgroud)
任何更改都会发生这种情况,包括我能找到的所有 AWS 编写的示例。AWS 中的各个地方都没有充分记录:CDK、SDK、API Gateway 和 CloudFormation,因此我很难找出那里出了什么问题?
云形成错误
Resource handler returned message: "Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression specified: *] (Service: ApiGateway, Status Code: 400, Request ID: [TRUNCATED], Extended Request ID: null)" (RequestToken: [TRUNCATED], HandlerErrorCode: InvalidRequest)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1388 次 |
| 最近记录: |