Ask Your Question
3

What is the method of retrieving data from a dictionary using a dynamic variable in an AWS Step Function?

asked 2021-05-27 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-31 12:00:00 +0000

scrum gravatar image

To retrieve data from a dictionary using a dynamic variable in an AWS Step Function, you can use the intrinsic function States.JsonPath and the syntax for referencing a specific key in a JSON object.

For example, if you have a dictionary stored in the state input variable ${MY_DICT} and you want to retrieve the value for a key that is stored in another state input variable ${MY_KEY}, you could use the following code:

"Result": {
  "Type": "Task",
  "Resource": "arn:aws:states:::states:jsonpath",
  "Parameters": {
    "$.value.$": "$.MY_DICT['$$.State.Input']['MY_KEY']"
  },
  "ResultPath": "$.result"
}

In this code, the $.value.$ parameter specifies where to store the result of the JSONPath expression, and the expression itself uses the ['$$.State.Input']['MY_KEY'] syntax to retrieve the value of the key stored in ${MY_KEY} from the dictionary stored in ${MY_DICT}. The result of the expression will be stored in the result property of the output of this state.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-05-27 11:00:00 +0000

Seen: 11 times

Last updated: May 31 '21