We can refer to the current time in AWS Step functions using "$$.State.EnteredTime", But that gives the ISO format. Is there a way to get the Epoch seconds/milliseconds? I want to add the TTL value in the DynamoDB based on that.
Is this possible? Or do I have to invoke a Lambda function only for the timestamp?
CodePudding user response:
This requires a Lambda Invoke Task. A small set of value transformations (e.g. string interpolation, JSON parsing) are natively handled by Intrinsic Functions. Most value transforms, however, including date manipulation, require an external task resource like Lambda.
"EpochExecutionTimeLambda": {
"Type": "Task",
"ResultPath": "$.epoch",
"Resource": "arn:aws:lambda:us-east-1:...",
"Parameters": {
"dateTime.$": "$$.State.EnteredTime"
}
The lambda handler is of course trivial:
exports.handler = async (event) => new Date(event.dateTime).valueOf()