使用 SQS 触发的无服务器不会将输出发送到配置的目标

Serverless triggered with SQS not send the output to configured destination

我使用的是无服务器框架,带有 SQS 的触发功能 hello 并且可以通过以下配置正确完成。

functions:
  hello:
    handler: handler.hello
    events:
    # Provide the ARN of your queue
      - sqs: arn:aws:sqs:us-east-1:abc:sqs_input

将目标添加到配置后

destinations:
  onSuccess: arn:aws:sqs:us-east-1:abc:sqs_output
  onFailure: arn:aws:sqs:us-east-1:abc:sqs_output

仅当我通过添加 --invocation-type Event 参数从 AWS CLI 调用它时它才能正常工作

aws lambda invoke --function-name testdestination-dev-hello --invocation-type Event response.json

但在我的例子中,输入将由输入 SQS 触发,我无法添加 --invocation-type Event 选项,所以我如何始终激活 SQS 目标?

遗憾的是,Lambda 目标仅适用于异步 Lambda 调用。 SQS 同步调用 Lambda,因此 Lambda 目的地不在此处 work/apply。

https://aws.amazon.com/blogs/compute/introducing-aws-lambda-destinations/

在这种情况下,您将不得不 post 在您的 Lambda 中以编程方式向 SQS 发送消息。