How to use AWS Lambda with API Gateway


May 16, 24

Reading Time

29 minutes





    Table of content
  • What is serverless?
  • Relinns Careers Website
  • What is AWS Lambda?
  • Relinns Careers Website
  • Some common terms related to AWS Lambda
  • Prerequisites
  • How to deploy AWS Lambda function
  • Add API Gateway as Lambda trigger
  • Conclusion
Relinns Careers Website

Before talking about AWS Lambda function, let us understand the term serverless.

What is serverless?

Serverless is a cloud based development approach. The developer focuses more on writing code and solving their business problems while the server is managed by AWS professionals. The advantage of a serverless application could be seen when auto-scaling the application. Not too long ago, developers had to anticipate application usage and add servers accordingly.

But, with the advent of serverless approach, bandwidth required to support the operation is managed by AWS. Resources could be scaled up or down depending on the computing needs at the time and you pay only for the resources you use.

The pay-as-you-go billing model helps teams to save time and money and be more focussed on customers' needs.

Now get back to our main topic.

What is AWS Lambda?

Definition as given on AWS, “AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers”, describes a serverless approach in a nutshell.

Using AWS Lambda has its own merits and demerits. Here I’m listing some of them.

Benefits of using AWS Lambda

  1. It follows serverless approach
  2. The AWS Lambda code could be called directly from a web or mobile application
  3. It could also be triggered by another AWS service, for example, SQS Queue, API Gateway, SNS, Cloudwatch, etc.
  4. AWS supports a variety of programming languages to write the code. It includes C#, Java, Node Js and Python.
  5. Developers can also use code compiling tools such as Maven or Gradle, and packages to build the functions.

Limitations of using AWS Lambda

AWS Lambda limit to amount of compute and storage resources. The limits are applied in each region and could be increased.

Its limitations could be categorized into two categories:

  1. Hard limit
  2. Soft limit

Soft Limits

Soft limits are those that are set as default values. They vary according to the region and could be increased by putting requests to the AWS support team. These limits are related to

  1. Concurrent Executions Limit
  2. Function and layer storage limit
  3. Elastic Network Interface per VPC

soft limits

Hard Limits

Hard limits are those which could not be modified even by the AWS support team. These limits are related to the

  1. function configuration
  2. function deployment
  3. function execution

hard limits

Some common terms related to AWS Lambda


A function is a program that is invoked by the Lambda. Lambda sends invocation events into the function which then processes the events and returns their responses.


It is the function execution environment selected to run the code. Runtime matches the language selected for the function.

Event source

Event source is an AWS service that triggers the function. Eg: HTTP request through API Gateway, SQS message available event, etc.

Lambda layer

The Lambda function imports several libraries and dependencies and zip them as a part of the build and deployment process. A Lambda layer is an archive that could be used to store additional code, such as dependencies and libraries, separated from the main build.


  1. AWS account
  2. IAM permissions to use.

How to deploy AWS Lambda function

Steps are given as below:

  1. Login to your AWS account.
  2. Visit
  3. Click: Get Started with AWS Lambda
  4. Click: Create function
  5. Fill in the basic information
    1. Select Author from scratch.
    2. Enter function name.
    3. Select the runtime environment.
    4. Click ‘Create function’. Leave other configuration to its default setting for the sake of simplicity.
  6. Add your code in the space provided in the section named ‘Code source’.
  7. Test your code, by clicking ‘Test’. A new tab will appear with the response. If everything is OK then you will get the response as shown below:

How to deploy AWS Lambda function - Image 5

Add API Gateway as Lambda trigger

As discussed above, Lambda could be triggered by the events from other AWS services. Lets create an API gateway to trigger the lambda function.

Steps to add API Gateway as a trigger:

  1. Select the lambda function to which trigger is to be added
  2. Click ‘Add trigger’
  3. Select the trigger: ‘API Gateway’
  4. Select
    1. HTTP API
    2. Security: Open
    3. Submit the form by clicking the ‘Add’ button.
  5. Click the ‘Configuration’ tab and find the API Gateway details. Copy the API endpoint.
  6. Click the endpoint and get the response.


AWS lambda is a serverless compute service which has the benefit of worry free auto-scaling. An event source in AWS could be used to trigger the Lambda function.

There are few restrictions with Lambda functions, but they have some thought behind them. It is meant to protect the developer from unintentional behaviour. To make most of AWS Lambda, the developer must be aware of these limitations.


Relinns Careers Page

Copyright © 2016 - 2024 Relinns Technologies Pvt. Ltd. All Rights Reserved.

Privacy policy
Follow us

Copyright © 2016 - 2024 Relinns Technologies Pvt. Ltd. All Rights Reserved.

Privacy policy