API Gateway Mapping Template for DynamoDB
20 July, 2021
BackYou can insert items into DDB with API Gateway Service Proxy. The Mapping Templates in API Gateway can transform requests so that POST requests are more readable.
The docs for API Gateway's Mapping Templates for DynamoDB are too verbose. So here's the shortcut:
{
"TableName":"Customers",
"Item":{
"name":{
"S":"$input.path('$.name')"
},
"contact":{
"N":"$input.path('$.contact')"
},
"email":{
"S":"$input.path('$.email')"
},
"uid":{
"N":"$input.path('$.uid')"
}
}
}
This will create template in API Gateway to PutItem into DDB so that the client need only to send a POST request like this:
{
"name":"Ethan",
"contact":555602142,
"email":"ethan@email.com",
"uid":1001
}
API Gateway setup
To configure API Gateway to DynamoDB, use the below config in the Integration Request.
Back