AWS Step Functions从Lambda输出中移除了payload属性。

huangapple go评论58阅读模式
英文:

AWS Step functions remove payload attribute from lambda output

问题

我有一个产生JSON对象数组的Lambda函数。我想将Lambda的结果传递给步骤函数,并将其放在给定的属性名称下。

运行Lambda的任务的输入:

{
"foo": "abc",
"bar": "def"
}

我想要的输出:

{
"foo": "abc",
"bar": "def",
"lambdaOutput": [
  {...},
  {...}
]
}

我认为ResultSelector + ResultPath应该能解决这个问题,但我卡住了。我尝试过以下内容:

"ResultSelector": {
        "lambdaOutput.$": "$.Payload",
      },
      "ResultPath": "$.lambdaOutput"

但这只会创建一个嵌套的结构:

{
"foo": "abc",
"bar": "def",
"lambdaOutput": 
    "lambdaOutput: {
    [ 
      {...},
      {...}
    ]
    }
}

我漏掉了什么?

英文:

I have a lambda that produces an array of json objects. I want the lambda result passed to a step function under a given attribute name.

Input to task that runs lambda:

{
"foo": "abc",
"bar": "def"
}

Output I want

{
"foo": "abc",
"bar": "def",
"lambdaOutput": [
  {...},
  {...}
]
}

I thought ResultSelector + ResultPath is supposed to solve this problem but I am stuck. I tried

"ResultSelector": {
        "lambdaOutput.$": "$.Payload",
      },
      "ResultPath": "$.lambdaOutput"

But this just creates a nested structure

{
"foo": "abc",
"bar": "def",
"lambdaOutput": 
    "lambdaOutput: {
    [ 
      {...},
      {...}
    ]
    }
}

What am i missing?

答案1

得分: 0

免责声明:我不是亚马逊状态语言专家,但尝试只使用以下代码:

{
  "ResultPath": "$.lambdaOutput"
}
英文:

Disclaimer: I'm not an Amazon States Language expert, but try just:

{
  ResultPath: "$.lambdaOutput"
}

答案2

得分: 0

你可以从 CDK 中指定 payloadResponseOnly,但不确定如何从控制台执行此操作。

链接:https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.LambdaInvoke.html#payloadresponseonly

英文:

Not sure how to do it from console, but from CDK, you can specify payloadResponseOnly

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.LambdaInvoke.html#payloadresponseonly

huangapple
  • 本文由 发表于 2023年8月4日 07:26:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76832127.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定