amazon-web-services - 无法将数组传递给 AWS StepFunction 中的下一个任务
问题描述
处理从 Lambda 调用中获取日期数组的 AWS StepFunction,然后传递给应将该数组作为参数传递给 lambda的Task 。
该Get Date Range
任务工作正常并输出日期数组:
{
"rng": [
"2019-05-07",
"2019-05-09"
]
}
...并且数组被传递到ProcessDateRange
任务中,但我无法为数组分配range
参数。
它实际上试图通过这个:"$.rng"
而不是这个:
[
"2019-05-07",
"2019-05-09"
]
这是状态机:
{
"StartAt": "Try",
"States": {
"Try": {
"Type": "Parallel",
"Branches": [{
"StartAt": "Get Date Range",
"States": {
"Get Date Range": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123456789:function:get-date-range",
"Parameters": {
"name": "thename",
"date_query": "SELECT date from sch.tbl_dates;",
"database": "the_db"
}
,
"ResultPath": "$.rng",
"TimeoutSeconds": 900,
"Next": "ProcessDateRange"
},
"ProcessDateRange": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123456789:function:process-date-range",
"Parameters": {
"range": "$.rng"
},
"ResultPath": "$",
"Next": "Exit"
},
"Exit": {
"Type": "Succeed"
}
}
}],
"Catch": [{
"ErrorEquals": ["States.ALL"],
"ResultPath": "$.Error",
"Next": "Failed"
}],
"Next": "Succeeded"
},
"Failed": {
"Type": "Fail",
"Cause": "There was an error. Please review the logs.",
"Error": "error"
},
"Succeeded": {
"Type": "Succeed"
}
}
}
解决方案
这是因为您对 Lambda 任务使用了错误的语法。要指定输入,您需要设置InputPath
密钥,例如:
"ProcessDateRange": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123456789:function:process-date-range",
"InputPath": "$.rng",
"ResultPath": "$",
"Next": "Exit"
},
推荐阅读
- performance - 如何改进这个 Spark 管道?
- java - 将Java库导入groovy脚本[SoapUI]
- ballerina - Ballerina 是否支持 Switch-case?
- java - 添加新的后,谷歌地图标记不会被删除
- angular - 从 onSubmit 值获取未定义
- c# - Xamarin 表单中缺少 TextInfo ToTitleCase
- java - 带有 @ManyToMany 字段的 Spring Data DTO 投影
- ios - 如何在 Swift 中使用领域过滤数据类型
- javascript - 我可以使用 node.js 监控现有的串行端口通信吗?
- angular - Angular/RxJS 6 - 如何对由 next() 触发的指令进行单元测试引发异常