How to concatenate character strings in step function for AWS Glue parameters?

0

HI All,

I have a step function to call an AWS Glue job with below step definition:

    "glue-redshift-call": {
      "Type": "Task",
      "Resource": "arn:aws:states:::glue:startJobRun.sync",
      "Parameters": {
        "JobName": "GlueJobRedshiftStoredProcCa-meJ8P3QMSC5p",
        "Arguments": {
          "--SQLStatement": "call dw_merge_vendor('TNG', 'ASENTINEL')"
        }
      },
      "Next": "post-processing"
    },

As shown above, SQLStatement parameter is hardcoded as call dw_merge_vendor('TNG', 'ASENTINEL') in this. But I need to make it dynamic, parameter based. As mentioned in Step Function new features Blogpost, I tried below syntax to make it dynamic, but it's not working. Would you be able to suggest the correct syntax if I am doing something wrong here?

"Arguments": {
  "--SQLStatement": "States.Format('call dw_merge_vendor('{}', '{}'),  ', $.param1, $.param2)"
}
AWS
質問済み 4年前3569ビュー
1回答
0
承認された回答

There are two issues with what you did. The first is that when you reference other variables or intrinsic functions, you need to append .$ to the key. The second is that when you need to include ' in the string, you need to escape them using \\. It should look like this:

"Arguments": {
"--SQLStatement.$": "States.Format('call dw_merge_vendor({}, {}),', $.param1, $.param2)"
}

If you need the params enclosed in ', you should use the following:

"Arguments": {
"--SQLStatement.$": "States.Format('call dw_merge_vendor(\\'{}\\', \\'{}\\'),', $.param1, $.param2)"
}
profile pictureAWS
エキスパート
Uri
回答済み 4年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ