Get Api in AWS Lambda

Devendra Patil
Canadiv’s Technology and Design
4 min readMay 22, 2023

What is AWS Lambda?

AWS Lambda is a computing service that lets you run code without provisioning or managing servers.

Why did we call lambda serverless?

The term ‘serverless’ is somewhat misleading, as servers still provide these backend services, but the vendor handles all of the server space and infrastructure concerns. Serverless means that the developers can do their work without having to worry about servers at all. that's why we call lambda a serverless function.

Now move toward the API creation:
1) simply get Api
In this API we are not using any compiler we are directly using the Aws console.

Step 1:
Sign up for your aws console if you haven't an account on aws if you have already registered there then log in with your credential as an IAM user shown below image.

You need to sign in as an IAM user role with your account id, IAM username & password then you successfully log in with your AWS console.

Step 2: Select a region as per your requirement like us-east-1 or etc as shown in the red rectangle in the image.

Step 3 :

Now click on lambda and click on createNewFunction after that this window is open for you:

so, you need to fill in all basic information like function name, and runtime this is dependent on which environment you are using for your code And Architecture and click on create function button then your function is ready.

Step 4:

now we need to add some code here I added some code to get a response from our get api as shown in I'm below image

simple im sending a “Hello from lambda” message from our lambda function to check whether our function is working or not. and click on the Deploy button near the Test Button shown in blue color in the image.

Step 4 :

click on API gateway and then click on Create API button on top of the right-hand side of your console. select HTTP API or REST API depending on your requirement I'm using HTTP api h

now click on Add Integration then there are two options for that

  1. lambda
  2. HTTP

select as per your requirement for now we are selecting lambda & add our api name in the below api name box shown in the image click on next and select your method like Get, post, put & delete we are creating get api so we choose to get method shown in images

then click on next

Define stage window is open click on next for this step after that
The review and Create window is open so quick review on our api with name and click on Create Api button and boom……our api is ready we get this screen with invoke URL

copy this invoke URL and pest in your Chrome and also we need the base path.

For Base Path: click on Routes then click on Get and you get the base path in routes details shown in the below image in the red color box

Now hit the full URL on your browser

And congratulations…. we have received a Hello from lambda message on our console.

And we conclude that our get Api is working successfully

Thanks, Everyone….

--

--