Skip to content

API Gateway Mapping Template

Resources

Conditionals

Let's say the payload looks like this:

{
  "event": {
    "op": "INSERT",
    "data": {
      "old": "something",
      "new": "something else"
    }
  }
}

Mapping template to set the MessageGroupId based on op would be:

#if($util.parseJson($input.body).event.op == "DELETE")
#set ($MessageGroupId = $util.parseJson($input.body).event.data.old)
#else
#set ($MessageGroupId = $util.parseJson($input.body).event.data.new)
#end
Action=SendMessage&MessageGroupId=$MessageGroupId&MessageBody=$util.urlEncode($input.body)

Set SQS Message Attributes

#set ($MessageGroupId = $util.parseJson($input.body).data.some_id)
Action=SendMessage&MessageGroupId=$MessageGroupId&MessageBody=$util.urlEncode($input.body)&MessageAttribute.1.Name=someattributename&MessageAttribute.1.Value.DataType=String&MessageAttribute.1.Value.StringValue=somevalue