Step Function: Dynamic input to ItemReader

0

I am working on a use case where I need to process a JSON file stored on S3 through a map state. Here is how I am passing the bucket name and Key to ItemReader:

"ItemReader": {
              "Resource": "arn:aws:states:::s3:getObject",
              "ReaderConfig": {
                "InputType": "JSON"
              },
              "Parameters": {
                "Bucket": "bucket-name",
                "Key.$": "$.StudyID"
              }
 }

The bucket name is static (can be sourced from state's input if necessary) and Key varies (sourced from state's input).

Question - Can we add a static prefix to the key? Like "Key.$": "static-prefix/$.StudyID". I have tested this but doesn't work. Is there any alternate solution to this?

Kamlesh
asked 9 months ago636 views
1 Answer
0

Hi.

Try using the States.Format Intrinsic function, it give you the possibility to manipulate the string.

"Key.$": "States.Format('static-prefix/{}.', $.StudyID)"

See the documentation for more information

profile picture
EXPERT
answered 9 months ago
profile picture
EXPERT
reviewed 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions