英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论