How To Create AWS Lambda Function Via Console

close up photo of programming of codes
Reading Time: 4 minutes

Hello Readers ! Hope you all are doing well , So here I am with the new post where we’ll see How To Create AWS Lambda Function Via Console . Before that we’ll see the basic introduction to Lambda and then we’ll go to the hands-on part . Stick to the end and follow the steps along with me .

Let’s Get Start !!!

INTRODUCTION

AWS LAMBDA

Lambda is a computing service that allows you to run your own code. Server less infrastructure eliminates the need for users to maintain servers and can automate operational processes.

Lambda supports many languages such as :

  • C#
  • Go
  • Java
  • Node. Js
  • Power Shell
  • Python Ruby

We can create lambdas using different ways. But in this post, I will focus that creating with AWS management console.

For creating lambda, unfortunately, you need to have an AWS account at the first.

I assume you have an AWS account and I continue to the next process.

Follow the below steps to do so :

Step 1: Log in

Log in to the AWS Management Console.

Put Your login details and sign in into the AWS Console .

Step 2: Find Lambda main page

If you success log in then you will find the management console main page. But we need to create lambda functions. That’s why please type lambda in the search area of the main page.

Or you can also click Lambda in the dashboard

Then you will be directed to the Lambda page. On that page you will see a screen as follows:

Step 3: Create a function

On the dashboard page , click on the Create Function option , and you will see that you on the creating functions configuration page.

On this page, the console will ask you for some information about your function(the italics were quoted from the AWS)

Function name: Enter a name that describes the purpose of your function. For example hello-function

Runtime info: Choose the language to use to write your function.

In this example, I chose Node.js 16.x version

Architecture: Choose the instruction set architecture you want for your function code.

I chose x86_64 architecture

Permissions: By default, Lambda will create an execution role with permissions to upload logs to Amazon Cloud Watch Logs. You can customise this default role later when adding triggers.

But if you have existing role , you can choose option 2 as :

If you need the add or edit advance settings you can click advanced settings:

Step 4: Develop the function

If your configuration has finished then click create a function which is located at the right bottom of the screen.

And you will find a screen that you can develop with your chosen language(Node.js, Ruby or Python).

Now you can develop your lambda function is in a created class(index.js). At the first, it is created very simple function by default:

exports.handler = async (event) => {

    // TODO implement

    const response = {

        statusCode: 200,

        body: JSON.stringify('Hello from Lambda!'),

    };

    return response;

};

Step 5: Test your function

After(or before if you have TDD approach) development, you can test your functions. But first, you must configure your test event. If you do not have it yet, please create a new one.

Go to Test –> Create new Test Event

After creating test-event as above and deploying the latest changes, click the test button and you will see the response of hello-function is as:

{

  "statusCode": 200,

  "body": "\"Hello from Lambda!\""

}

Step 6: Deploy your function

If all processes are okay as you want, then you can deploy your lambda.

Go to the Actions options and click on Delete Functions option as:

Congratulations! you have created a successful lambda function along with its deletion.

CONCLUSION

So here we have learned How To Create AWS Lambda Function Via Console. I hope you have learned something new and interesting . In case of any doubt you can ask me .

Stay tuned 🙂

Thank you for reading.

Hope it helps…

REFERENCE

CLICK HERE

Written by 

Deeksha Tripathi is a Software Consultant at Knoldus Inc Software. She has a keen interest toward learning new technologies. Her practice area is DevOps. When not working, she will be busy in listening music , and spending time with her family .

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading