Skip to content

Instantly share code, notes, and snippets.

@chris
Last active November 23, 2020 18:52
Show Gist options
  • Save chris/6684fbf90a3435ea9984d14f4a3b4b02 to your computer and use it in GitHub Desktop.
Save chris/6684fbf90a3435ea9984d14f4a3b4b02 to your computer and use it in GitHub Desktop.
Just the VTL template portion of the API Gateway - DynamoDB proxy serverless config
RequestTemplates:
application/json: |
#set($inputRoot = $input.path('$'))
{
"RequestItems": {
"${self:resources.Resources.EventsTable.Properties.TableName}": [
#foreach($event in $inputRoot.event)
{
"PutRequest": {
"Item": {
"UserID" : { "S": "$context.authorizer.claims.sub" },
"TimeUTC" : { "S": "$event.time" },
"Lat": { "N": "$event.lat" },
"Lng": { "N": "$event.lng" },
"UUID" : { "S": "$event.uuid"},
"Sensor" : { "S": "$event.sensor_name" },
"Reading" : { "N": "$event.reading_value" },
"Active" : { "BOOL": "$event.is_active" },
}
}
}#if($foreach.hasNext),#end
#end
]
},
"ReturnConsumedCapacity": "NONE",
"ReturnItemCollectionMetrics": "NONE"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment