How to integrate AWS API Gateway with FIFO SQS? It is easy to integrate API Gateway with standard SQS with the template. But for FIFO queue, we need to pass groupId and deduplicationId.
You can extract the MessageGroupId
and MessageDeduplicationId
from the response of API gateway. eg: if the payload is something like below, you can extract the any properties from the payload. Clear video tutorial here. https://www.youtube.com/watch?v=dXa9KA-G9Dg
Assume the payload is like this:
{
"data" :{
"jobNumber": "123456"
}
}
Then the template in api gateway is below. It extract the jobNumber from the payload and set to MessageGroupId. Here the MessageDeduplicationId is getting from the context.
#set($dedupId = $context.requestId)
#set($groupId = $input.json('$.data.jobNumber'))
Action=SendMessage&MessageBody=$input.body&MessageGroupId=$groupId&MessageDeduplicationId=$dedupId
The original post: Unable to send message from API Gateway to FIFO SQS