Using API Gateway To Get Data From Dynamo DB Without Using AWS Lambda

Today I was stuck finding a solution on a very specific problem: to find a way that to get the data from Dynamo DB table without using Lambda service or without writing any piece of code in Lambda.

As you probably already know,that API Gateway has integration types.In that aws service is one which helps to connect to other services makes execution directly.Using these AWS services Let’s find a solution…!!!

Amazon API Gateway : Amazon API Gateway is an AWS service for creating, publishing, maintaining, monitoring, and securing REST and WebSocket APIs at any scale. API developers can create APIs that access AWS or other web services as well as data stored in the aws cloud.

There may be application-specific restrictions you’d like to place on the API calls being made to AWS services that you would not be able to enforce if clients integrated with the AWS APIs directly. You might want to enable your application to integrate with very specific functionality that an AWS service provides, without the need to manage access keys and secret keys that AWS APIs require.


In this, the client uses either GET, PUT, POST, DELETE methods in API Gateway and integrate with dynamo DB using aws service and get the data from a particular table. Without writing any piece of code in Lambda we can get the data from the table.

Steps for getting data from Dynamo-DB from API Gateway without using Lambda:

  • Firstly log in to the aws console and Go to Services. In services click on DynamoDB.
Image 1: Login to the console and at services click DynamoDB.
  • Select a table.
Image 2: Click on any table in DynamoDB you want to get deatils.
  • View the details. And copy the ARN for further use.
Image 3: It gives the overview details of your table.

Go to Services and click on IAM.

Image 4: Go to services and click IAM
  • Create Policy.
Image 5: Create policies.
  • Choose service.
Image 6: Choose service.
  • Click DynamoDB service. And add Actions.
Image 7: Also add Actions to your policy.
  • At Actions click on Query.
Image 8: Select the Actions based on your requirement.
  • Add the above ARN to this Resource.
Image 9: Add the ARN of the table.
  • And then Review Policy.
Image 10: Review policy.
  • Give name to the policy. And create a policy.
Image 11: Give name to the policy and create it.
  • Your Policy is displayed here.
Image 12: Your policy will be displayed in this manner.
  • Create a Role
Image 13: Create a Role.
  • Click on API Gateway and then click on Next.
Image 14: We are using API Gateway so click on it.
  • Click on Next.
Image 15: Click on next.
  • Give your Role name and Create.
Image 16: Give name to your role.
  • Your Role will be displayed here.
Image 17: Your role will be displayed in this manner.
  • Click on Attach policies to attach the customised policy that we created before.
Image 18: Click on Attach Policy to add the customized policy.
  • Click on the policy you created and then click on Attach Policy.
Image 19:Add the policy to your role.
  • Your Policies will be displayed here.
Image 20:Your Policies to the role will be displayed here.
  • Go to Services and click on API Gateway. And then create a API.
Image 21: Create an API.
  • Give your API name and create.
Image 22: Give name to the API.
  • Give your Resource name and create a Resource.
Image 23: Create a resource.
  • Create sub reource for your resource.
Image 24: Create a sub resource.
  • Add method.
Image 25: Add a method.
  • Click on Intergation Request.
Image 26:Click on Integration Request.
  • Give the details and save.
Image 27: Give the necessary details and save it.
  • Click on Mapping Templates.
Image 28: Click on Mapping Templates.
  • Add a mapping template and save.
Image 29: Add body mapping template and save.
  • Now, click on Test.
Image 30: Click on Test button.
  • Give your id that you want to test.
Image 31: Give the id that you want to Test.
  • It fetches the data from DB and gives Response.
Image 32: Response will be displayed in this manner.
  • Click on Deploy API
Image 33: Click on Deploy API.
  • Give your stage name and click on deploy.
Image 34: Give the stage name and deploy.
  • It generates a URL.
Image 35: It generates a URL.
  • When you click on URL, it shows the response in this manner if the corresponding particular ID is Not in the DB.
Image 36: If the id is not in DB it gives response in this manner.
  • When you click on URL, it shows the response in this manner if the corresponding particular ID is In the DB.
Image 37: If the id is in DB then it gives the response in this manner.

Using this solution, we can directly get the data from Dynamo DB using API Gateway without writing any piece of code in Lambda function.

Ok, that’s it. I hope you found this case useful! See you next time.