7

How to create lambda function in AWS?

 2 years ago
source link: https://blog.knoldus.com/how-to-create-lambda-function-in-aws/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Reading Time: 3 minutes

Introduction:

In this blog, I will show you how to create lambda function. But first we will see what is lambda function.Lambda is a server light service on AWS where you can only pay for what you are going to use in terms of compute usage and so there is no charge when your code is not running.Lambda function is a small anonymous function. It is a function that take any number of arguments, but can only have one expression. It reduce the number of lines of code when compared to normal python function defined using def keyword.

How to create lambda function:

Step1: First log into the AWS console. Once you navigate to the service, search for lambda and this will open the lambda management console. Here you can see all the existing function listed.

lfO275xw16A9jKxnKnjsSIIdpVCfER8LfVrjM6rQL-59zaWUh_r7aNejLWCSr6Xw2fkiaDK0W7XxHWpQW_-Qut6SmQvJ5VlKfUYAxzA-mA5sqqCtWBFwVAd63yqazOxfaO4gd18C

jEpTIuPLmBIDEXbfK69whVWVS_w6fbMLqmUkMOcEC-PLy-OZ48Rx--e5V9CQi6EfX3Q5pVdgosdCzH4SM547OQSnVV_ikQJpIc2m8oEV7CwKtUGqN7XduGJNEuYb9QEecsHekGDB

Step 2: Let us create one function. Click on create function. There is two options (i) Author from scratch (ii) blueprints. Blueprints are the pre- configured template.

pyAdiRPy6XLnBZ4zITFndO7gyZ0txhLpY9tVaxStPa8TA_H-fThEl_ZUyR8Sjgiqh6ODedtHNq3JwDpgrewH9TTSRpwgLQycGaxcprJrpiJhlH6zlJq_HUWYrwKckdklk-lDo2fg

iye9dMAIflhDxOgRjUzsWAnvcjYaTJ2VvNf7byEUMBz0Nl-6cR9bABl_MmQakmtVG3Yg-t4p0LtuEEKCB-2h95KN2yJYb-MAw59GRKKLTi_2BtdRgfgpUtaHarE28pT-odM-w6an

Step 3: So for now we are going with author from scratch. Here we define the name of lambda function. Lets define it as test and select the runtime i.e python. You can also choose an existing role if you have or you can create one by selecting the create a custom role and it will redirect you to the new webpage. Click on allow and it will create a pre- configured role that is lambda equals to execution.

ndF3X8nwYgrprfookuQz4WwjwSSr_3DpDX0eXRTk5uaGkIzTLRnqnjwJpG4j1_1nH5HhQ_oSSTxMly82y6GpnDH9gnHIXhT_zCkkSsVW-r43pdwU7SLPHMxVppo3RV_5NRqwQlci

Here role is already created. So select the choose an existing role that is lambda_basic_execution and click on create function. So it will create the function name test with the ARN. Here is our code paste which is below the function code.

Step4: So you can print the statement and you can save it and test it. While you click on test, it will ask you to define an event. So we will define an event let’s say test and you can see it’s execution result is success. So you can click on return and see your return statement that is Hello which is the return statement and this is the print statement that we have printed i.e. my test lambda function.

Step 5:Apart from that you can go to the report that is duration it is 0.25 milliseconds to build duration is 100 milliseconds. The memory size that we have allocated and the max memory used is 22 MB from 128 MB. This is how we create lambda function.

Conclusion:

 Lambda function is just like any normal python function, except that it has no name when defining it, and it is contained in one line of code. A lambda function evaluates an expression for a given argument.

Scala Future


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK