我正在尝试从上一步中删除仅在选择任务中使用的字段。 我有这个 StepFunction
{
"StartAt": "ConversionStep",
"States": {
"ConversionStep": {
"Type": "Task",
"TimeoutSeconds": 30,
"Resource": "arn:aws:lambda:region:account-id:function:conversion-step",
"Retry": [
{
"ErrorEquals": [
"RetryError",
"States.Timeout"
],
"IntervalSeconds": 30,
"MaxAttempts": 3
}
],
"Catch": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"Next": "Failure"
}
],
"Next": "ChoiceStep"
},
"ChoiceStep": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.processEvent",
"BooleanEquals": true,
"Next": "PublishStep"
}
],
"Default": "Failure"
},
"PublishStep": {
"Type": "Task",
"Resource": "arn:aws:states:::events:putEvents",
"Parameters": {
"Entries": [
{
"Detail.$": "$",
"EventBusName": "example-event-bus",
"DetailType": "example-detail-type",
"Source": "EXAMPLE_SOURCE"
}
]
},
"Retry": [
{
"ErrorEquals": [
"RetryError",
"States.Timeout"
],
"IntervalSeconds": 30,
"MaxAttempts": 3
}
],
"Catch": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"Next": "Failure"
}
],
"Next": "Success"
},
"Success": {
"Type": "Succeed"
},
"Failure": {
"Type": "Fail"
}
}
}
在转换步骤中,在事件中添加
processEvent
。
我需要在发布步骤中发送没有此字段的转换步骤结果
"Detail.$": "$",
有没有办法可以在不创建另一个 Lambda 步骤的情况下做到这一点? 选择步骤没有结果过滤功能。
现在可以通过使用 Transform Operator 最近推出的对 JSONata 的支持来实现这一点。
您需要更新状态才能使用
"QueryLanguage": "JSONata"
(您可以对整个状态机执行此操作,或者如果您不想更改其余部分,则可以仅针对此状态执行此操作,并将“$”(JSONPath 输入引用)替换为像这样的东西:
"{% $states.input ~> | ** | {}, ['processEvent'] | %}"