Das*_*son 2 python json aws-step-functions serverless aws-sam
我的 params.json 输入中有一部分用于一组步骤函数,并且我想修改一些参数以包含在输入参数中呈现的日期时间。
"Predictor": {
"PredictorName": "normal_name_/*DATETIME HERE*/",
"ForecastHorizon": 181,
. . .
},
Run Code Online (Sandbox Code Playgroud)
我目前正在通过修改函数第一步中的输入参数来完成此操作,但是这是有问题的,因为每次运行它时,它都会重新渲染日期时间,并且我想“锁定”日期,就像步骤一样函数执行已创建。这可能吗?
这可以在状态机定义本身内完成。执行的开始时间可作为Context Object中的 IS0 8601 字符串获得。使用内部函数 States.Format,在传递任务中将日期时间与您的姓名前缀连接起来。
"TimestampNamePass": {
"Type": "Pass",
"ResultPath": "$.Predictor",
"Parameters": {
"Name.$": "States.Format('normal_name_{}', $$.Execution.StartTime)"
},
"Next": "Success"
},
"Predictor": {
"PredictorName.$": "$.Predictor.Name",
"ForecastHorizon": 181,
. . .
},
Run Code Online (Sandbox Code Playgroud)
TimestampNamePass输出:
{
"Comment": "Insert your JSON here",
"Predictor": {
"Name": "normal_name_2022-01-27T14:09:19.196Z"
}
}
Run Code Online (Sandbox Code Playgroud)