我已经使用SAM规范配置了与API网关的lambda代理集成,并通过传递X-Amz-Invocation-Type异步调用lambda:“'Event'” Headers

ApiGateway:
      Type: AWS::Serverless::Api
      Properties:
        StageName: prod
        DefinitionBody:
          swagger: "2.0"
          info:
            title:
              Ref: AWS::StackName
            description: API endpoint for invoking LambdaFunction
            version: 1.0.0
          paths:
            /items:
              post:
                consumes: ["application/json"]
                produces: ["application/json"]
                responses: {}
                x-amazon-apigateway-integration:
                  type: "aws_proxy"
                  uri:
                    Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaFunction.Arn}/invocations
                  passthroughBehavior: "when_no_match"
                  httpMethod: "POST"
                  requestParameters:
                      integration.request.header.X-Amz-Invocation-Type: "'Event'"

问题是lambda返回空响应(调用异步),因此API Gateway会抛出以下错误

星期三11月14日08:03:14 UTC 2018:由于配置错误导致执行失败:格式错误的Lambda代理响应Wed Nov 14 08:03:14 UTC 2018:方法已完成,状态:502

这种行为有望吗?我是否必须明确定义回复?我不想总是扔200,因为我也想发送错误的请求和未经授权的错误 . 什么是避免这个问题的解决方案?