【问题标题】:How to pass input to the task arguments in step function Map state?如何将输入传递给步骤函数映射状态中的任务参数?
【发布时间】:2020-02-25 20:04:38
【问题描述】:

我创建了一个状态机来并行运行一些 Glue/ETL 作业。我正在试验 Map 状态以利用动态并行性。下面是阶跃函数定义:

{
 "StartAt": "Map",
 "States": {
   "Map": {
     "Type": "Map",
     "InputPath": "$.data",
     "ItemsPath": "$.array",
     "MaxConcurrency": 2,
     "Iterator": {
       "StartAt": "glue job",
       "States": {
         "glue Job": {
           "Type": "Task",
           "Resource": "arn:aws:states:::glue:startJobRun.sync",
           "End": true,
           "Parameters": {
             "JobName": "glue-etl-job",
             "Arguments": {
               "--db": "db-dev",
               "--file": "$.file",
               "--bucket": "$.bucket"
          }
        }
      }
    }
  },
  "Catch": [
    {
      "ErrorEquals": [
        "States.ALL"
      ],
      "Next": "NotifyError"
    }
  ],
  "Next": "NotifySuccess"
},

}
}

传递给step函数的输入格式是这样的:

{
 "data": {
   "array": [
     {"file": "path-to-file1", "bucket": "bucket-name1"},
     {"file": "path-to-file2", "bucket": "bucket-name2"},
   ]
 }
}

问题是filebucket 作业参数没有得到解决,它们被传递给像$.file$.bucket 这样的胶水作业。如何从输入中传递参数实际值?

【问题讨论】:

    标签: aws-glue aws-step-functions


    【解决方案1】:

    使用状态字段作为参数时,您需要在参数的'.$'末尾添加。

    "--file.$": "$.file",
    "--bucket.$": "$.bucket"
    

    如需完整指南,请查看规格表。 https://states-language.net/spec.html#parameters

    【讨论】:

      猜你喜欢
      • 2021-11-14
      • 2022-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多