Build REST services on AWS
Building REST APIs that are secure, scalable and manageable is quite a challenging task. You can read my earlier blog to understand more about it. It might take weeks if not months to build an API that can support your mobile APP. Your task doesn’t end here as your database also needs to be scalable to support increased traffic once your APP is viral.
Thanks to Amazon for providing wonderful services, building APIs with scalable architecture is no more a rocket science. All this can be handled very easily by selecting two AWS offerings:
- Dynamodb - fully managed, scalable NOSQL DB.
- Amazon API Gateway - Fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale.
APIs can be built in two easy steps:
- Create table in DynamoDB
By default DnamoDB always returns data in JSON format. This solves half of challenge in delivering REST APIs on DB - convert data stored in tables to JSON object
2. Configure API Gateway to use DynamoDB
This solves rest half by providing configurable options to control - throttling, authorization etc.
Table can be easily created using AWS management console(DynamoDB). Configuring API gateway to consume data from DynamoDB is little tricky. Sample configuration shown below should guide developers in this:
Set Method parameters as below
In “Integration Request” Set Mapping template to Dynamodb to map input parameters to Dynamodb Query
Map Dynamodb response to HTTP response in “Integration response“
Bingo!! your Rest API is ready to support heavy traffic created by APP.