Hi my step function cdk code is something like this
tasks.LambdaInvoke(self, "my_step_function",
lambda_function=my_lambda,
output_path="$.Payload",
payload=stepfunctions.TaskInput.from_object({
"payload.$": "$",
"job_id.$": "$$.Job.Id"
})
and when doing post request I am sending request like this :
scan_resp = requests.post(BASE_URL '/start', json={'job_id': job_id},
headers={'x-api-key': api_key})
and getting this error
{
"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}}'"
}
CodePudding user response:
The $$.
prefix refers to the execution's Context Object. It has no Job
key. Perhaps you mean $$.Execution.Id
? If Job.Id
is part of your own defined input, prefix it with (a single) $.
.