【问题标题】:step function input issue阶跃函数输入问题
【发布时间】:2022-07-07 02:53:21
【问题描述】:

嗨,我的步进函数 cdk 代码是这样的

tasks.LambdaInvoke(self, "my_step_function",
                                        lambda_function=my_lambda,
                                        output_path="$.Payload",
                                        payload=stepfunctions.TaskInput.from_object({
                                            "payload.$": "$",
                                            "job_id.$": "$$.Job.Id"
                                        })

在进行发布请求时,我正在发送这样的请求:

scan_resp = requests.post(BASE_URL + '/start', json={'job_id': job_id},
                              headers={'x-api-key': api_key})

并收到此错误

{
  "error": "States.Runtime",
  "cause": "An error occurred while executing the state my_lambda' (entered at the event id #2). The JSONPath '$$.Job.Id' specified for the field 'job_id.$' could not be found in the input '{\"Execution\":{\"Id\":\"arn:aws:states:us-west-2:935463345537:execution:on-demand-scan-flow-orchestrator:fd51a151-70d4-4d8a-b203-fe3ea5ce7269\",\"Input\":{\"data\":{\"job_id\":30150908},\"apiInfo\":{\"httpMethod\":\"POST\",\"apiKey\":\"zWLyDJkvnSWaiK4Rf\"}},\"Name\":\"fd51a151-70d4-4d8a-b203-fe3ea5ce7269\",\"RoleArn\":\"arn:aws:iam::935463345537:role/on-demand-scan-stack-myorchestratorR-1LCG5GDN3L44F\",\"StartTime\":\"2022-07-06T14:05:17.175Z\"},\"StateMachine\":{\"Id\":\"arn:aws:states:us-west-2:935463345537:stateMachine:my-orchestrator\",\"Name\":\"my-function\"},\"State\":{\"Name\":\"my-function\",\"EnteredTime\":\"2022-07-06T14:05:17.222Z\",\"RetryCount\":0}}'"
}

【问题讨论】:

  • 您是使用 CDK 来支持资源还是以编程方式调用它?
  • @smac2020 是使用 cdk 创建的阶跃函数。这是 stepfunction 的第一步

标签: python amazon-web-services boto3 aws-cdk


【解决方案1】:

$$ 前缀指的是执行的Context Object。它没有Job 键。也许你的意思是$$.Execution.Id?如果Job.Id 是您自己定义的输入的一部分,请在其前面加上一个美元符号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-11
    • 1970-01-01
    • 2012-10-16
    • 1970-01-01
    • 2019-02-21
    • 2015-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多