簡體   English   中英

StepFunctionsLocal 不接受 $$ 參數

[英]StepFunctionsLocal does not accept $$ parameter

如此所述,AWS state 機器定義語法允許使用$$.Map.Item.Value訪問 map state 迭代中更高 scope 的屬性:

{
  "StartAt": "ExampleMapState",
  "States": {
    "ExampleMapState": {
      "Type": "Map",
      "Parameters": {
               "ContextValue.$": "$$.Map.Item.Value"
             },
      "Iterator": {
         "StartAt": "TestPass",
         "States": {
           "TestPass": {
             "Type": "Pass",    
             "End": true
           }
         }
      },
      "End": true
    }
  }
} 

但是,當使用 StepFunctionsLocal(Java 和 Docker 版本)運行時,此示例定義本身會引發 SCHEMA_VALIDATION_FAILED 錯誤:

SCHEMA_VALIDATION_FAILED: The value for the field 'ContextValue.$' must be a valid JSONPath or a valid intrinsic function call at /States/ExampleMapState/Parameters

我是否遺漏了什么或者這是 StepFunctionsLocal 中的錯誤?

檢查您的腳本以確保您已正確轉義雙 $$

經過一些測試后,我最好的猜測是它是aws cli 中的一個錯誤(或者聲明sfn定義時的一個轉義問題,如此處所述,盡管我無法做到這一點)。

無論如何,我使用這個示例定義嘗試boto3而不是cli

>>> definition = """
... {
...   "Comment": "Accessing context object in a state machine",
...   "StartAt": "Get execution context data",
...   "States": {
...     "Get execution context data": {
...       "Type": "Pass",
...       "Parameters": {
...         "startTime.$": "$$.Execution.StartTime",
...         "execName.$": "$$.Execution.Name"
...       },
...       "ResultPath": "$.executionContext",
...       "End": true
...     }
...   }
... }"""
>>> role = "arn:aws:iam::012345678901:role/DummyRole"
>>> r = client.create_state_machine(name="Test", definition=definition, roleArn=role)
>>> pprint.pprint(r)
{'ResponseMetadata': {'HTTPHeaders': {'content-length': '161',
                                      'date': 'Fri, 30 Dec 2022 19:46:31 GMT',
                                      'server': 'Jetty(9.4.43.v20210629)'},
                      'HTTPStatusCode': 200,
                      'RetryAttempts': 0},
 'creationDate': datetime.datetime(2022, 12, 30, 14, 46, 31, 770000, tzinfo=tzlocal()),
 'stateMachineArn': 'arn:aws:states:us-west-2:123456789012:stateMachine:Test'}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM