Design a site like this with
Get started

[6] [ProjectX] – Using AWS API Gateway with AWS Lambda

In our previous blog post, we created Lambda function and used AWS Console Test button to invoke it.

However, in practical scenarios, we will need something else to expose this function on internet and a way to invoke it. This is what AWS API Gateway service does best.

So, in this blog post, we will configure API Gateway service to call our Lambda function

Big Picture:

Below diagram depicts what we are trying to do.

Creating API


Log into your AWS Console and open API Gateway service landing page


Click Create API button. Fill the details as shown below and click Create API button located below


You will see that the API has been created for you as shown below.


Now we must create what is called a Resource. Click Action dropdown above and select Create Resource option


Fill the values as shown below and click Create Resource button


Next it will show you that resource is created. Now click Actions drop-down and this time select Create Method option


Click-the drop down and select GET. Then click tick mark besides it


You will see the screen shown below. Type myFullName in the Lambda Function text box and click Save button at bottom


You will get a prompt like below. Click OK.


You will see screen like below, which confirms your API and its Methods are created.


Now we will go ahead and Deploy the API. Select Deploy API option from Actions drop-down


Next window will prompt you for Stage details. Enter information as show below


Finally, your API is deployed, and you will get an Invoke URL as shown below

Copy this Invoke URL someplace, as we will require it for testing.

This completes Creation of API using AWS API Gateway. Now we have created a callable wrapper around our Lambda function, which can be called directly from Internet.

 Check Association with Lambda

How can we be sure that this API we created has been associated as callable wrapper to our Lambda function? Let’s check.

Go to your Lambda function and open Designer

As you can see above, the API Gateway is now associated to left side of our Lambda function.

Testing API and Lambda

Let’s now proceed with testing the API and in turn Lambda function also.


For this you have to download an API testing utility called Postman


After downloading and installing it, let’s start with testing our API. Open Postman and enter values as shown below


Drop-down Method – GET

Body: raw

Value in text box: {“firstName”: “Jason”,”lastName”: “Bourne”}

Note: Replace with your URL that you had noted earlier and make note of resource name (fullname) appended at end of the Url


Click on Send button and you should see the results as below


Awesome. It works. If you want, you can go to CloudWatch and check LogStreams. It will have logs of our latest call

With this, we have a Serverless function that can be invoked on internet from anywhere in the world. Cool right.


This completes creation of API as wrapper to our Lambda function. You can give this URL of API to anyone all over the world and they will be able to invoke your Lambda function.


3 thoughts on “[6] [ProjectX] – Using AWS API Gateway with AWS Lambda

  1. […] are already familiar with other ways provided by AWS for resource creation like AWS Console, AWS CLI, AWS SAM, AWS CloudFormation etc. Now we have one more option […]

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: