How to: Clean the Contents of AWS Step Function Path Variables


AWS Step Functions provides serverless flow orchestration capability.


Normally you would execute a flow orchestration once per transaction, but sometimes you need to iterate through many transactions in a loop as part of your orchestration. In this case where you iterate in sequence (and not in parallel) you sometimes need to ensure the path variables aren’t re-used i.e. are ‘clean’ between iterations.

This happened to me recently when the target system I was working with could only handle one transaction at a time, not a typical scenario in an enterprise IT environment.


Set a “pass” type task in the step function flow, and add the path variables you want to keep under “parameters” section as follows:

"CleanVars": {
              "Type": "Pass",
              "InputPath": "$",
              "Parameters": {
                "FileName.$": "$.FileName",
                "BucketName.$": "$.BucketName",
                "data.$": "$.data",
                "iterator.$": "$.iterator"
              "ResultPath": "$",
              "Next": "NextTask"

Author Details

Riaan Ingram
Riaan is a Principal Consultant with over 20+ years’ IT architecture, design and development experience. Riaan has a strong technical, hands on background and specialises in developing and integrating enterprise business solutions. Riaan has in depth knowledge of integration as well as cloud patterns & technologies and is an expert in the planning, design and implementation of API first, event driven, microservices, low/no code integration approaches.

You might be interested in these related insights