Lambda microservice to read data from DynamoDB via API Gateway

Dipali Kulshrestha
1 min readMay 26, 2021

--

1.Create Role to give access for Lambda, API Gateway, DynamoDB [Lambda-Api-DD]

2.Create dynamo DB table ‘result_table’ [details given below]

Dynamo DB table:Table: result_table
PartitionKey: EnrollmentID
SortKey: Exam
Sample Data:EnrollmentID Exam Result Sub1 Sub2 Sub3

EI00001 IITJEE Pass 90 92 84
EI00002 IITJEE Pass 80 89 78
EI00003 IITJEE Pass 70 92 70
EI00004 IITJEE Fail 49 35 30
EP00001 PMT Fail 56 34 22

3.Create Lambda function ‘APIDD’ using python runtime and API Gateway as trigger [refer attachment for script]

4. Create API Gateway ‘ReadFromDynamoDBAPI’, Create route ’readfromdd’ & method ‘GET’ and Deploy it using Dev stage

i) Go To APIs and pick 3rd option REST API (public), Click on Build

ii) Create a New API with name ‘ReadDDAPI’, Create API

iii) Go To Actions & Create Resource ‘readfromdd’

iv) Go To Actions & Create Method for this resource, Method ‘GET’ and integrate it with your Lambda function APIDD created in step 3, and Save this.

v) Next, Go to Stages, and click on Deploy API, Create a new stage ‘dev’ and deploy.

5. Grab the Invoke URL from stage (Dev), followed by /<route-name> to see the response.

i) Expand the stage and click on GET method and pick the invoke url e.g

https://cskfu8gqnd.execute-api.us-east-1.amazonaws.com/dev/readfromdd

ii) Hit this url and and it should return desired record.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Dipali Kulshrestha
Dipali Kulshrestha

No responses yet

Write a response