如何解决AWS Step Functions:如何使用传递步骤“重命名”输入参数
States:
'Analyze Report':
Type: Task
Resource: 'arn:aws:states:::lambda:invoke'
Parameters:
FunctionName: '(redacted)'
OutputPath: '$.Payload'
Next: 'Setup Email'
'Setup Email':
Type: Pass
Result:
recipients: '$.accounts'
subject: 'some email subject'
body: 'some email body'
ResultPath: '$'
Next: 'Send Email'
'Send Email':
Type: Task
Resource: 'arn:aws:states:::lambda:invoke'
Parameters:
FunctionName: '(redacted)'
OutputPath: '$.Payload'
Next: '(some downstream task)'
与 Analyze Report
步骤关联的 lambda 函数的输出格式为:
{
"accounts": ["foo","bar","baz"],"error_message": null,"success": true
}
与 Send Email
步骤关联的 lambda 函数需要以下形式的输入:
{
"recipients": ["foo","subject": "some email subject","body": "some email body"
}
在查看状态函数的测试执行时,似乎 Setup Email
步骤没有成功地将 $.accounts
字符串插入 {{1} 的 accounts
数组输出} 步。相反,Analyze Report
步骤会看到以下输入:
Send Email
我尝试了设置等各种组合:
{
"recipients": "$.accounts","body": "some email body"
}
但它似乎不想插入。 AWS 提供的文档似乎有点缺乏这种方式。
TL;DR:如何使用 # (within the `Setup Email` step)
Result:
'recipients.$': '$.accounts'
类型的阶跃函数步骤有效地“重命名”输入参数(使用数组值)?
解决方法
您需要在 Parameters
状态下使用 Pass
。下面是一个例子:
{
"Comment": "A Hello World example of the Amazon States Language using Pass states","StartAt": "Hello","States": {
"Hello": {
"Type": "Pass","Parameters": {
"newName.$": "$.oldName"
},"Next": "World"
},"World": {
"Type": "Pass","Result": "World","End": true
}
}
}
当我使用 { "oldName": "some value" }
的负载运行上面的代码时,第二个状态的输入是 { "newName": "some value" }
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。