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
gefragt vor 4 Jahren3570 Aufrufe
1 Antwort
0
Akzeptierte Antwort

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
EXPERTE
Uri
beantwortet vor 4 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen