I have a section of my params.json input for a set of step functions, and I would like to modify some of the parameters to include a datetime that gets rendered in the input parameters.
"Predictor": {
"PredictorName": "normal_name_/*DATETIME HERE*/",
"ForecastHorizon": 181,
. . .
},
I am currently doing it by modifying the input parameters in the first step of the function, however this is problematic as every time I run it it will re render the datetime and I'd like to "lock in" the date as whenever the step function execution was created. Is this possible?
This can be done within the State Machine definition itself. The execution's start time is available as an IS0 8601 string from the Context Object. Using the intrinsic function States.Format
, concatenate the date-time with your name prefix in a Pass Task.
"TimestampNamePass": {
"Type": "Pass",
"ResultPath": "$.Predictor",
"Parameters": {
"Name.$": "States.Format('normal_name_{}', $$.Execution.StartTime)"
},
"Next": "Success"
},
"Predictor": {
"PredictorName.$": "$.Predictor.Name",
"ForecastHorizon": 181,
. . .
},
TimestampNamePass
Output:
{
"Comment": "Insert your JSON here",
"Predictor": {
"Name": "normal_name_2022-01-27T14:09:19.196Z"
}
}