
I tried passing the query string and path parameters from API gateway to lambda
Introduction
Hemanth of Alliance Department here. In this blog, I tried passing the query string and path parameters from API gateway to lambda.
AWS Lambda
A serverless compute service that 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 vis Amazon API Gateway, changes to objects in S3, and many others.
API Gateway
A fully managed service that makes developers easily create, publish, maintain, monitor, and secure APIs at any scale. Using API Gateway can 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.
Demo
Go to lambda and click on create function
Type function name and click on create function
Making changes to code, here i want to receive a greeting message in query string and click on deploy
Now let's test it by clicking on test, then configure test and making the following changes, finally click on save
clicking on the created test
working as expected
Now configuring the test event and making changes to greeting, name and click save
Testing again
Now open the API gateway and click on build RestAPI
click on new api, give an API name and click on create API
Now click on slash next option and then resource
Make following changes and click on resource
select name, actions and select create method
select get and make the following changes
select the integration request
Make the following change and click save
Now deploying the API
Select new stage and click deploy
In resources click on test
Entering path, query strings and clicking on test
Getting the expected outcome
Conclusion
Hope with this you get an idea of how to pass the query string and path parameters from API gateway to lambda. Thank you for seeing the blog till the end.