Select specific portions of the raw input using the InputPath filter - Amazon Step Functions
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Select specific portions of the raw input using the InputPath filter

Use the InputPath filter to select a specific portion of the input payload.

If you don't specify InputPath, its value defaults to $, which causes the state's task to refer to the entire raw input instead of a specific portion.

Step 1: Create a state machine

Important

Ensure that your state machine is under the same Amazon account and Region as the Lambda function you created earlier.

  1. Use the Parallel state example you learned about in Tutorial 4 to create a new state machine. Make sure your workflow prototype looks similar to the following prototype.

  2. Configure the integrations for the check-identity and check-address Lambda functions. For information about creating the Lambda functions and using them in your state machine, see Step 1: Create the Lambda functions to perform the required checks and Step 2: Update the workflow – Add parallel tasks to be performed.

  3. For Payload, make sure you keep the default selection of Use state input as payload.

  4. Choose Next and then do the steps 1 through 3 in Step 1: Save the state machine of Tutorial 5 to create a new state machine. For this tutorial, name your state machine WorkflowInputOutput.

Step 2: Run the state machine

  1. On the WorkflowInputOutput page, choose Start execution.

  2. (Optional) To identify your execution, you can specify a name for it in the Name box. By default, Step Functions automatically generates a unique execution name.

    Note

    Step Functions allows you to create names for state machines, executions, activities, and labels that contain non-ASCII characters. These non-ASCII names don't work with Amazon CloudWatch. To ensure that you can track CloudWatch metrics, choose a name that uses only ASCII characters.

  3. In the Input area, add the following JSON data as the execution input.

    { "data": { "firstname": "Jane", "lastname": "Doe", "identity": { "email": "jdoe@example.com", "ssn": "123-45-6789" }, "address": { "street": "123 Main St", "city": "Columbus", "state": "OH", "zip": "43219" } } }
  4. Choose Start execution.

  5. The state machine execution results in an error because you’ve not specified what parts of the execution input the check-identity and check-address Lambda functions must use to perform the required identity and address verification.

  6. Continue to Step 3 of this tutorial to fix the error.

Step 3: Use the InputPath filter to select specific parts of an execution input

  1. On the Execution Details page, choose Edit state machine.

  2. To verify the applicant’s identity as mentioned in the execution input provided in Step 2: Run the state machine, edit the Verify identity task definition as follows:

    ... { "StartAt": "Verify identity", "States": { "Verify identity": { "Type": "Task", "Resource": "arn:aws-cn:states:::lambda:invoke", "InputPath": "$.data.identity", "Parameters": { "Payload.$": "$", "FunctionName": "arn:aws-cn:lambda:us-west-2:123456789012:function:check-identity:$LATEST" }, "End": true } } } ...

    Consequently, the following JSON data becomes available as input for the check-identity function.

    { "email": "jdoe@example.com", "ssn": "123-45-6789" }
  3. To verify the applicant’s address as mentioned in the execution input, edit the Verify address task definition as follows:

    ... { "StartAt": "Verify address", "States": { "Verify address": { "Type": "Task", "Resource": "arn:aws:states:::lambda:invoke", "InputPath": "$.data.address", "Parameters": { "Payload.$": "$", "FunctionName": "arn:aws:lambda:us-east-1:123456789012:function:check-address:$LATEST" }, "End": true } } } ...

    Consequently, the following JSON data becomes available as input for the check-address function.

    { "street": "123 Main St", "city": "Columbus", "state": "OH", "zip": "43219" }
  4. Choose Start execution. The state machine execution now completes successfully.