Search code examples
amazon-web-servicesaws-step-functions

In AWS Step Functions, can you format parameter values with static string?


In AWS Step Functions, we can use parameters from previous steps as inputs using the following syntax.

"Parameters": {
        "Details": {
          "weight.$": "$.product.weight",
          "unit": "grams"
        }
      }

As an example, say product.weight. is 500. Can I configure a parameter that will receive a value of 500 grams?

For example, something like this:

"Parameters": {
        "Details": {
          "formatted_weight.$": "{$.product.weight} grams",
        }
      }

Solution

  • Use the States.Format intrinsic function to interpolate a string:

    "Parameters": {
            "Details": {
              "formatted_weight.$": "States.Format('{} grams', $.product.weight)",
            }
          }