HttpApi 与 AWS::ApiGatewayV2::integration 如何覆盖响应正文

Sub*_*ham 5 amazon-web-services aws-cloudformation aws-api-gateway

我想覆盖从此集成发送的响应正文。我指的是这个链接https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html

它说要使用overwrite:$response.body. 但这不起作用。我给出错误说“无效的目标参数”

APIVersionIntegration:
  Type: AWS::ApiGatewayV2::Integration
  Properties:
    ApiId: !Ref HttpApi
    ConnectionType: INTERNET
    CredentialsArn: !GetAtt MyHttpApiRole.Arn
    IntegrationType: AWS_PROXY
    RequestParameters:
      MessageBody: "$request.body"
      QueueUrl: !Ref DataPublisherSQS
    ResponseParameters:
      "200":
        ResponseParameters:
          - Source: "application/json"
            Destination: "overwrite:header.content-type"
          - Source: ""
            Destination: "overwrite:$response.body"
    IntegrationSubtype: "SQS-SendMessage"
    # IntegrationMethod: POST
    PayloadFormatVersion: "1.0"
Run Code Online (Sandbox Code Playgroud)

Yve*_* M. 1

我有完全相同的问题(与 SQS 集成,我想返回一个空的 JSON)。

阅读文档,似乎无法覆盖响应正文,只能修改标头和状态代码: https: //docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping。 html#http-api-映射-响应参数

响应参数映射键

也许唯一的方法是在 Lambda 中包装 SQS 消息发送