is it possible to use JSON Numeric aggregation functions in API gateway map

0

As the subject says, I am looking if it is possible to use JSON Numeric aggregation functions in API gateway mapping templates?
I have the below template and I would want to add the "ttl" column as a future date.
{
"TableName": "api",
"Item": {
"ingestId": {
"S": "$context.requestId"
},
"ttl": {
"N": "$context.requestTimeEpoch"
}
}
}

So I wanted to try the sum() function of the request Epoch time and some number to get a future date as the result.
Any suggestions and inputs are welcome.

gsk308
已提问 3 年前347 查看次数
1 回答
1

I had to use the set variable before the JSON structure. I was trying it inside and was failing at the syntax validation.
#set($milliseconds = $context.requestTimeEpoch + 2*86400000)

This sets the milliseconds variable to current epoch + 2 days and this variable can be used in subsequent JSON.

gsk308
已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则