amazon-web-services - HttpApi 与 AWS::ApiGatewayV2::integration 如何覆盖响应正文

标签 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"

最佳答案

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

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

Response parameter mapping keys

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

关于amazon-web-services - HttpApi 与 AWS::ApiGatewayV2::integration 如何覆盖响应正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73463191/

相关文章:

MySQL:InnoDB 与 MyISAM:如何以及为什么要改变 (Amazon RDS)?

amazon-web-services - 如何通过http触发器从AWS SNS触发GCP云功能(私有(private))

aws-cloudformation - ECS 和应用程序负载均衡器

aws-lambda - 无服务器应用程序中的缓存失效

Django 在 S3ResponseError : 301 Moved Permanently 中收集静态结果

java - DynamoDB 的程序化运行状况检查?

amazon-web-services - Cloudformation资源创建/删除超时时间

amazon-web-services - 设置 Tableau Server 以在 AWS GovCloud 上运行

aws-lambda - 在 API Gateway 端点后面本地测试 AWS Lambda

python - AWS Chalice 从 S3 返回图像文件