Skip to content

Instantly share code, notes, and snippets.

@vidanov
Last active November 28, 2021 10:16
Show Gist options
  • Save vidanov/1931ad602212997bbe356ad854352349 to your computer and use it in GitHub Desktop.
Save vidanov/1931ad602212997bbe356ad854352349 to your computer and use it in GitHub Desktop.
AWS Step functions. InputPath, OutputPath, ResultPath

AWS Step functions

InputPath, OutputPath, ResultPath

  • InputPath -> the part of the original JSON payload to take to the step
  • OutPutPath -> the part of the original JSON payload to return after the step is completed
  • ResultPath -> here you can define a node to store the output you create in the step.

Please note "output" node is visible in the step function logs and here in the doc, but you do not have it in the function input. It means { "output": "1.05" } will be just

"1.05" in the real world.

Input for your Lambda function from Step Function is what you can find in the node "input" in the step function logs. For example: to read a file name from a S3 event you can use this:

event.detail.requestParameters.key.

Payload

	{"version": "0",
	    "id": "8d6f9246-b781-44f8-a026-f1c1ab2c61f0",
	    "detail-type": "AWS API Call via CloudTrail",
	    "source": "aws.s3",
	    "account": "123456789012",
	    "time": "2018-09-12T00:25:10Z",
	    "region": "us-east-2",
	    "resources": [],
	    "detail": {
	      "eventVersion": "1.05",
	      "userIdentity": {
	        "type": "IAMUser",
	        "principalId": "AKIAIOSFODNN7EXAMPLE",
	        "arn": "arn:aws:iam::123456789012:user/username",
	        "accountId": "123456789012",
	        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
	        "userName": "username",
	        "sessionContext": {
	          "attributes": {
	            "creationDate": "2018-09-11T20:10:38Z",
	            "mfaAuthenticated": "true"
	          }
	        },
	        "invokedBy": "signin.amazonaws.com"
	      }
	  
	  }

Examples

Input Path

Pass Step Definition

   	 "HelloWorld": {
   	   "Type": "Pass",
   	   "End": true,
   	    "InputPath":"$.detail.eventVersion"
   	 }

Result

  {
  		"output": "1.05"
  }

OutputPath

Pass Step Definition

"HelloWorld": {
      "Type": "Pass",
      "End": true,
       "OutputPath":"$.version"
    }

Result

	{
	    "output": "0"
   }

ResultPath

Pass Step Definition

     "HelloWorld": {
      "Type": "Pass",
      "End": true,
       "InputPath":"$.detail.eventVersion",
       "ResultPath":"$.mynode"
  	  }

Result

	{  "output": {... the original payload plus...,
	
					      "mynode": "1.05"  }
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment