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
preguntada hace 3 años351 visualizaciones
1 Respuesta
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
respondido hace 3 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas