The Startup
Published in

The Startup

Execute a Basic AWS Lambda Function Without Any Triggers

AWS lambda

AWS refers to Lambda as a serverless computing service. Let’s understand what server-less is. It has the following three main characteristics —

  • Pay for the services you use.
  • You don’t have to manage the infrastructure.
  • You can scale the service automatically up and down.

AWS lambda lets the user to run code without provisioning or managing servers and the user needs to pay for how much they use. The user can also scale it up and down according to their needs.

How does AWS lambda works?

To make AWS lambda work, following three steps should be considered —

  1. Upload code to AWS lambda.
  2. Set the triggers.
  3. Run the code.

But in this blog, we’ll make AWS lambda to run the code without setting up the trigger.

What is a trigger?

Trigger is an event that causes the AWS lambda function to execute. Let’s understand this with an example of API gateway triggers. when an HTTP request comes to the system through the API gateway, then API gateway will trigger the AWS lambda function.

Programming model for AWS Lambda

The lambda programming model has three parts —

  1. Trigger
  2. Handler function
  3. Code

As we have already learnt about triggers in the previous section, let’s now understand handler function. It is the function that will be executed upon invocation. A typical anatomy of handler function is as follows —

module.exports.handler = function( event, context, callback)

The above handler function has three parameters —

(a) event — It is the data that is sent during the function call. The event object changes depending on what triggers the Lambda.

(b) context — It contains the methods available to interact with the runtime information.

(c) callback — It is used to return information to the one that invokes/triggers the Lambda. This parameter is not mandatory and not available in all cases.

Setting up the environment

First of all, you must have an AWS account. If you have the access to root user account, it is recommended to create an IAM user with administrator access and then login to AWS management console using the IAM user credentials. Go to the search bar and type in ‘lambda’. Then click on the ‘lambda’ which will be displayed as the search result. you’ll be redirected to the lambda page.

Now that we’ve understood the basics of AWS lambda and also created the proper environment, lets dive in to create a basic lambda function. As the AWS lambda supports many languages, we’ll use Node.js here.

Step 1: Click on the create function button and then Author from scratch. Fill in all the blanks under the Basic information. Lets give our Lambda function a name of Function_Zero. Select Runtime as Node.js 12.x. Then under Permissions select Create a new role with basic Lambda permissions as an Execution role. Then hit Create function button.

Step 2: A new page will be opened where we’ll write our lambda function. Scroll down to the text editor. Inside index.js, write the following code and deploy it—

exports.handler = async(event) => {
console.log("Hello world, This is Lambda");}

Step 3:Click on the Test button and then we’ll create new test template to pass information in the event object as an input to the function. Let’s give our Event name as testEvt. We’ll keep the default event object that is in JSON format and we’ll click on Create button.

Step 4: Now, we’ll again click on the Test button to run the code. After execution, the Execution result will be displayed, where we can see the results of console.log(event); and console.log("Hello world, This is Lambda"); in the log output section.


In this article, we have understood the meaning of server-less computing, the functioning of AWS Lambda, and programming model of AWS Lambda. Finally, we’ve created an AWS lambda function without any triggers.

For this project, I took help from AWS Lambda documentation. Particularly, Create a Lambda function with the console.


Documentation on AWS Lambda



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store