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
gefragt vor 3 Jahren347 Aufrufe
1 Antwort
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
beantwortet vor 3 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen