Creating an Shop API of GET items with DynamoDB, lambda and API Gateway using AWS




It stands for Application Program interface which helps in connection of two applications, computers, or between computer programs to talk to each other. It is used to access data, server software, or other applications and has been around for some time. Each time anyone uses a particular app for weather updates or good restaurants in an app API is used.

API Gateway

A fully managed service that makes developers easily create, publish, maintain, monitor, and secure APIs at any scale. API Gateway can be used to create Restful APIs and WebSocket APIs which have real-time two-way communication applications. It is a front door for applications to access data, business logic, or functionality from your backend services.

AWS Lambda

A serverless compute service which runs code as a reply to events and automatically takes care of the bottom resources. It runs code on high availability compute infrastructure and performs all the administration of the compute resources. A few examples are HTTP requests via Amazon API Gateway, changes to objects in S3, and many others.


An Amazon AWS Web Services database that is fully managed, serverless, key-value NoSQL database, has high-performance applications at any scale. It has the following benefits such as built-in security, continuous backups, automated multi-region replication, in-memory caching, and data export tools

Refer to the below article on how to access data directly from Lambda instead of DynamoDB


Search for API Gateway in the AWS Console and click build on HTTP API Give an API Name and click next No changes right now in the configure routes and click next Give a name to the stage and keep the auto-deploy as the default Review and click on create Adding a path in the routes and click create Choosing the GET method, entering the path, and clicking create Go to lambda and click on create function Click on author from scratch, give a function name, keep other things as default and click on create function Go to DynamoDB and click create table Write down a table name, partition key and choose the customized settings In Capacity mode select on-demand Keep the rest as it is and click on create table Creating items in the shop-item table Click on create an item Clicking duplicate and adding onion date Make below changes in code source and clicking deploy In the configuration, tab choose permission and click edit on the execution role section In order to attach the policy click the below link Clicking on inline policy Review the policy and click create policy thus the lambda can now access the DynamoDB Going back to Routes of API Gateway click on GET and click on attach integration In the integration target choose “lambda function”, integration target “get item” and click create Copy the invoke URL of API Paste the invoke URL in the new tab with “/item/34” and get the result Paste the invoke URL in the new tab with “/item/78” and get the result