banner

KuchBhiLearning - A free website to learn and code

This is a good learning site. This contains details of cloud computing, AWS, AWS-CDK, AWS-SDK codes and examples including S3, Redis, lambda, api-gateway, cloudfront, cloudformation.

 

How to create an AWS Lambda function

AWS Lambda significantly accelerates and simplifies how developers can develop and maintain their code. AWS Lambda eliminates the need for developer/cloud operations team to manage any servers. This is known as serverless infrastructure.
Based on the load lambda can be upscaled. Another great feature about serverless is that you pay only when you use.

AWS lambda's main resources are Lambda functions, which contain a granular piece of code that performs a specific task. To deploy a Lambda function, users upload source code and configure parameters, such as the following

  • Triggers
  • Permission
There are many advanced topics which we will cover in next blog
  • Database Proxy
  • Memory
  • Virtual Private Cloud (VPC)
  • Concurrency
  • Elastic File System
  • Error Handling

We will be using AWS console for creating the lambda.

Step 1

An easy way to create an AWS Lambda function is through the Create function button on the Lambda console.



Step 2

After clicking the Create function button, the next screen shows several options for the function's code. 

  • Author from scratch. Create your own code from a Hello World example.
  • Use a blueprint. AWS' code blueprints include built-in AWS integrations with other services and common uses. These blueprints can save a significant amount of time when developing Lambda functions.
  • Container image. Container images stored in Amazon Elastic Container Registry are also useful to launch new Lambda functions.
  • Browse serverless app repository. In AWS Serverless Application Repository, users can find various helpful products.

For this example, let's select Author from scratch to create our function.


Step 3

Let's proceed to create a Lambda function built from scratch. The basic configuration fields include function name, runtime and permissions. Supported runtimes include programming languages such as Node.js, Go, Python, Ruby, Java, C# and .NET. Lambda also supports custom runtimes, which a developer can implement in any language that can be compiled in the Amazon Linux OS


By default, lambda will create an execution role with permission to upload logs to amazon cloud watch logs. You can customize this default role later when adding triggers.



Click on Create Function.

Lambda is ready to be executed.



Navigate to Test tab and have the following trigger event.




Click on Test button.


We have successfully created and tested a lambda. 🥳🎉

Conclusion

We have learnt how to create a simple lambda function and how to run.

1 comment:

If you have any doubts, Please let me know

Copyright 2022, KuchBhiLearning - A free website to learn and code. All rights Reserved.
| Designed by Yaseen Shariff