How do I pass the input of a step function startExecution to the executed function

0

I'm trying to use a step function startExecution state to break up a state machine into 2 parts and I want to pass the input of the startExecution function to the executed function, e.g.,

"Process chunk": {
            "Type": "Task",
            "Resource": "arn:aws:states:::states:startExecution",
            "Parameters": {
              "StateMachineArn": "arn:aws:states:us-west-1:12345:stateMachine:Ingestion-process-parts",
              "Input": "$.input.MessageDetails"  
            },
            "End": true,
            "ResultPath": "$.input.MessageDetails"
          }

where the startExecution input is

"input": {
    "MessageNumber": 0,
    "MessageDetails": "<an S3 URL>"
  },

but no matter what I try for the input to the executed state machine it just passes a literal value, i.e., in the case above, instead of passing the input of the startExecution state to the executed function it passes

"input": {
    "MessageDetails": "$.input.MessageDetails",
    "AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID": "arn:aws:states:us-west-1:1234:execution:Ingestion-Chunk-CSV:055ede1a-dc03-4412-a341-d3b6611dbed4"
  },

Note that the same input parsing Does work for the Result:

{
  "name": "Process chunk",
  "output": {
    "MessageNumber": 0,
    "MessageDetails": "<an S3 URL>",

It doesn't appear the the normal approach of parsing the input using $... works for this purpose. Is it possible to do what I want?

thanks

질문됨 일 년 전2004회 조회
1개 답변
1
수락된 답변

As documented here,

For key-value pairs where the value is selected using a path, the key name must end in .$

What you need to do is the following:

"Process chunk": {
     "Type": "Task",
     "Resource": "arn:aws:states:::states:startExecution",
     "Parameters": {
          "StateMachineArn": "arn:aws:states:us-west-1:12345:stateMachine:Ingestion-process-parts",
          "Input.$": "$.input.MessageDetails"  
     },
     "End": true,
     "ResultPath": "$.input.MessageDetails"
 }
profile pictureAWS
전문가
Uri
답변함 일 년 전
profile pictureAWS
전문가
검토됨 일 년 전
  • Thanks Uri, that worked great!

    I did, however, find that using "StateMachineArn.$": "$$.StateMachine.Id" resulted in an attempted recursion, rather than calling the function I wanted, so I left that as before.

  • My bad of course. I thought you are passing your own ARN. Of course you need to pass the ARN that you want to invoke so you are correct. Will edit my answer.

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

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

질문 답변하기에 대한 가이드라인

관련 콘텐츠