How to create a simple API with AWS using AWS API Gateway, DynamoDB, IAM?!
- 3 minsRest has become one of the most significant technologies for web applications. Its importance is likely to continue growing fast.
Rest is short for representational state transfer. The whole idea behind a restful API is that we can use it to transfer data around.
Let’s learn how to build an API using Amazon’s API gateway and Dynamodb table (Simple API) for clarifying in practice way.
Great so let know how to get a Dynamodb table to hook up to the API gateway? and to give me a publicly accessible API URL
1- Click on dynamoDB I’m going to create a table to call this test the partition key is like the primary key, Lets going to call this (coracoid) just for the fun of it, For a string and use default settings should be fine. let’s start doing that put a couple of lines to create an item and here you got crocoID and then will give it a string of 1, 2, 3
Create an item and below you got crocoID and then we’re going to give it a string of it. Change id name of a crocoid to any id.
2- Choose ‘Create Policy’ to create new policy
3- Choose ‘Create New Role’ and attach the policy that we already made before.
4- Choose ‘Amazon API Gateway’ and Get Started. We will create a New API name. Also, we’re going to call this dynamo test We need to create the resource and, we’re just going to call this crocoID the field that we’re going to use and so this is going to end up being the URL
Click on ‘Integration Request’ to mapping templates ‘application/json’ for a template to Amazon API gateway as a proxy for DynamoDB
5- Click ‘test’ to do tests The first one I did was one so if we click one and click test it will work!
6- Click ‘Save’ and Replace callback ‘Key1 value is’ & Save and Test
Next thing you have to do is to deploy it. So, under actions select ‘deploy API’ deployment stage there’s going to be new. I’m going to call this test because that’s what everything else has been called deploy and now here it’s giving
Finally, publicly API URL Work fine!