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
asked 3 years ago338 views
1 Answer
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
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions