내용으로 건너뛰기

Step Functions JSONATA- Wait Time does not accept variable "seconds - state input" variable

0

Hello Team,

Step-functions wait time feature in JSON-PATH accepts seconds which can be a variable based on state-input, while JSONATA is not supporting that feature, is there any plan to include that ?

질문됨 일 년 전270회 조회
3개 답변
1

Hi,

Are you referring to using the output from another state as an input parameter to define the wait time? If that's the case, check out the following code. I've tested it with an AWS Express Step Function.

{
  "QueryLanguage": "JSONata",
  "Comment": "A description of my state machine",
  "StartAt": "Initialization",
  "States": {
    "Initialization": {
      "Type": "Pass",
      "Next": "Wait",
      "Output": {
        "waitSeconds": 1
      }
    },
    "Wait": {
      "Type": "Wait",
      "Seconds": "{% $states.input.waitSeconds %}",
      "End": true
    }
  }
}
전문가
답변함 일 년 전
0

Thank you for your question about Step Functions and JSONata. You're correct that there's a difference in how wait times are handled between JSONPath and JSONata in AWS Step Functions.

In JSONPath-based states, you can indeed use variables based on state input to specify wait times in the Wait state. However, it's important to note that Step Functions has recently introduced variables and JSONata as new features to manage state and transform data, which changes how some operations are performed.

While JSONata offers more capabilities compared to JSONPath within Step Functions, including advanced data manipulation and transformation, the current implementation does not directly support using variables for wait times in the same way as JSONPath.

However, JSONata does provide more functions and operators than JSONPath and intrinsic functions in Step Functions. This means that while the exact syntax for specifying wait times might be different, you may be able to achieve similar functionality using JSONata's advanced features.

As for plans to include direct support for variables in wait times using JSONata, AWS has not publicly announced any specific plans for this feature. AWS regularly updates and improves its services based on customer feedback and needs, so it's possible that this functionality could be added in the future.

In the meantime, you might want to explore alternative approaches using JSONata's existing capabilities to achieve your desired workflow. If this functionality is critical for your use case, you may want to consider using JSONPath for the specific states that require variable-based wait times, as Step Functions allows you to use different query languages at the task level.

For the most up-to-date information on Step Functions features and capabilities, it's always best to check the official AWS documentation or reach out to AWS support for specific feature requests or workarounds.

Sources
Simplifying developer experience with variables and JSONata in AWS Step Functions | AWS Compute Blog
What is Step Functions? - AWS Step Functions

답변함 일 년 전
0

Just a note to confirm that Mikel Del Tio's answer works:

"Wait": {
  "Type": "Wait",
  "QueryLanguage": "JSONata",
  "Seconds": "{% $states.input.waitSeconds %}"
}

Note that you can also reference a $variable from the Assign expression of an earlier state.

Wouldn't it be amazing if we could also write…

"SampleChoiceState": {
  "Type": "Choice",
  "QueryLanguage": "JSONata",
  "Choices": [
    {
      "Condition": "{% CONDITION_A %}",
      "Next": "{% $nextStateA %}"
    },
    ...

(Of course I can see why AWS doesn't allow it.)

답변함 5달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.