{"id":4077,"date":"2020-06-04T06:11:42","date_gmt":"2020-06-04T06:11:42","guid":{"rendered":"https:\/\/www.genesesolution.com\/bd\/?p=4077"},"modified":"2021-08-26T11:54:28","modified_gmt":"2021-08-26T11:54:28","slug":"getting-started-with-aws-lambda-using-node-js","status":"publish","type":"post","link":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/","title":{"rendered":"Getting Started with AWS Lambda using Node JS"},"content":{"rendered":"\n[et_pb_section fb_built=&#8221;1&#8243; specialty=&#8221;on&#8221; _builder_version=&#8221;3.22&#8243;][et_pb_column type=&#8221;3_4&#8243; specialty_columns=&#8221;3&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_row_inner admin_label=&#8221;Row&#8221; _builder_version=&#8221;3.25&#8243;][et_pb_column_inner saved_specialty_column_type=&#8221;3_4&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_text _builder_version=&#8221;4.4.6&#8243; hover_enabled=&#8221;0&#8243;]<p><span style=\"font-weight: 400;\">A webinar and demo session on Getting Started with AWS Lambda using Node JS was held on 15th May 2020, Friday starting from 5:00 pm to 7:00 pm NPT.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The whole session started with an introduction to AWS Lambda and a hands-on demo which will explain How to Get Started with AWS Lambda using Node JS.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. It is a computing service that runs code in response to events and automatically manages the computing resources required by that code. AWS Lambda lets users run code without provisioning or managing servers. With Lambda, users can run code for virtually any type of application or backend service &#8211; all with zero administration. Just upload the code and Lambda takes care of everything required to run and scale your code with high availability. Users can set up their code to automatically trigger from other AWS services or call it directly from any web or mobile app.\u00a0 \u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><b>AWS Lambda Use cases: <\/b><\/span><\/p>\n<ul>\n<li><b>As an event-driven compute service<br \/> <\/b><\/li>\n<li><span style=\"font-weight: 400;\">AWS Lambda uses code in response to the events.\u00a0<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Example: AWS S3 (Different events) <\/span><span style=\"font-weight: 400;\"><br \/> <\/span><\/p>\n<ul>\n<li><b>As a compute service<br \/> <\/b><\/li>\n<li><span style=\"font-weight: 400;\">AWS Lambda uses code in response to HTTP requests.\u00a0<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Example: API Gateway (Making API calls)<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/compute-service-1.png\" width=\"512\" height=\"152\" alt=\"\" class=\"wp-image-4081 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/compute-service-1.png 512w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/compute-service-1-480x143.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 512px, 100vw\" \/><\/span><\/p>\n<p><b><i>Fig: Illustration of How AWS Lambda works<\/i><\/b><\/p>\n<p><span style=\"font-weight: 400;\">One major factor which makes the AWS Lambda more popular and mostly liked by the users is its scalability. It scales the running environment automatically as per the memory allocation to run the function. For example: When memory allocated to a function is increased from 128MB to 500MB, parallelly it also increases the processing power, networking capabilities and so on.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Similarly, lambda functions also can be triggered by HTTP requests. For this, we should make use of API Gateway services in between to create the API Endpoints.\u00a0<\/span><\/p>\n<p><b>This is the case when a single request is made to the Lambda function through API Gateway.<\/b><\/p>\n<p><b><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/api-gateway.png\" width=\"652\" height=\"127\" alt=\"\" class=\"wp-image-4082 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/api-gateway.png 652w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/api-gateway-480x93.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 652px, 100vw\" \/><\/b><\/p>\n<p><b><span style=\"font-weight: 400;\">When multiple HTTP requests are made to a lambda function at the same time, each request executes the function separately i.e. independently. Behind the scene, each new request runs on a new container separately. So, when thousands of requests are made, thousands of containers run in the background.<\/span><\/b><\/p>\n<p><b><span style=\"font-weight: 400;\">This is the case when multiple requests are made on the Lambda function.<\/span><\/b><\/p>\n<p><b><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/lambda.png\" width=\"716\" height=\"231\" alt=\"\" class=\"wp-image-4083 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/lambda.png 716w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/lambda-480x155.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 716px, 100vw\" \/><\/span><\/b><\/p>\n<p><span style=\"font-weight: 400;\">In layman terms, Serverless Architecture is what a company uses to streamline its IT mechanisms, being provided by a vendor company. Though the serverless architecture does have the servers, it&#8217;s just that the company is not managing them anymore, unlike traditional servers. <\/span><span style=\"font-weight: 400;\"><br \/> <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Serverless architecture is a way to build and run applications and services without having to manage infrastructure. User applications still run on servers, but all the server management is done by AWS. Serverless can also mean applications where server-side logic is still written by the application developer, but, unlike traditional architectures, it&#8217;s run in stateless compute containers that are event-triggered, ephemeral (may only last for one invocation), and fully managed by a third party.<\/span><span style=\"font-weight: 400;\"><br \/> <\/span><\/p>\n<p><span style=\"font-weight: 400;\">However, the difference between Traditional and Serverless architectures can be illustrated via the below image:<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/serverless.png\" width=\"740\" height=\"363\" alt=\"\" class=\"wp-image-4084 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/serverless.png 740w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/serverless-480x235.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 740px, 100vw\" \/><\/span><\/p>\n<p><span style=\"font-weight: 400;\">In serverless, you pay for what you use which means you incur a cost when code runs, you pay per byte of storage actually used, and the hidden infrastructural support for scaling all of this is built into these numbers. It\u2019s truly a metered service. For example, on AWS Lambda you pay $0.20 per million requests when code is executed. In practice, this typically means you can pay 70\u201390% less for your infrastructure compared with even the cloud equivalent.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Therefore, Scaling is also a gift for startups. Usually, the gap between the Minimum Viable Product and \u2018Production Ready\u2019 can mean rewriting and redesigning the app.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can build serverless backends using AWS Lambda to handle web, mobile, Internet of Things (IoT), and 3rd party API requests. Take advantage of Lambda&#8217;s consistent performance controls, such as multiple memory configurations and Provisioned Concurrency, for building latency-sensitive applications at any scale. <\/span><span style=\"font-weight: 400;\"><br \/> <\/span><span style=\"font-weight: 400;\"><br \/> <\/span><b>You can also build:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Real-time file processing<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Real-time stream processing<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Extract, Transform, Load\u00a0<\/span><span style=\"font-weight: 400;\"><\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/f.png\" width=\"625\" height=\"173\" alt=\"\" class=\"wp-image-4085 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/f.png 625w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/f-480x133.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 625px, 100vw\" \/><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/g.png\" width=\"748\" height=\"358\" alt=\"\" class=\"wp-image-4086 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/g.png 748w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/g-480x230.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 748px, 100vw\" \/><\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-weight: 400;\"><b><i>Fig: Demo of Architecture<\/i><\/b><\/span><\/p>\n<p><b>Below are the steps to Get Started with AWS Lambda using Node JS:<\/b><\/p>\n<p><b>Step 1: Go to AWS Management Console and choose Lambda under compute category service.<\/b><\/p>\n<p><b><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/console.jpg\" width=\"1600\" height=\"871\" alt=\"\" class=\"wp-image-4087 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/console.jpg 1600w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/console-1280x697.jpg 1280w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/console-980x533.jpg 980w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/console-480x261.jpg 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) and (max-width: 1280px) 1280px, (min-width: 1281px) 1600px, 100vw\" \/><\/b><\/p>\n<p><b>Step 2: Choose Create Function.<\/b><\/p>\n<p><b><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function.png\" width=\"1284\" height=\"304\" alt=\"\" class=\"wp-image-4088 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function.png 1284w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function-1280x303.png 1280w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function-980x232.png 980w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function-480x114.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) and (max-width: 1280px) 1280px, (min-width: 1281px) 1284px, 100vw\" \/><\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><b>Step 3: Choose Author from scratch.<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">We also can choose the other two options if we want to work on already built functions blueprints. Here we are choosing \u201cAuthor from Scratch\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/ss1.png\" width=\"1600\" height=\"631\" alt=\"\" class=\"wp-image-4093 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/ss1.png 1600w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/ss1-1280x505.png 1280w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/ss1-980x386.png 980w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/ss1-480x189.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) and (max-width: 1280px) 1280px, (min-width: 1281px) 1600px, 100vw\" \/><\/span><\/p>\n<p><b>Step 4: Fill up the basic information.<\/b><\/p>\n<p><span style=\"font-weight: 400;\">We can give our own function name. We can select a runtime in which we will write our function code. Currently, lambda functions can be written on different runtimes like Node.js, Python, Ruby, and so on.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/information.png\" width=\"966\" height=\"491\" alt=\"\" class=\"wp-image-4094 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/information.png 966w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/information-480x244.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 966px, 100vw\" \/><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><b>Note: <\/b>We can create a new role with basic permissions for now but if our function code needs access to other AWS services, we need to create a new role with the particular service permission. And we have to choose the role in this step from the option \u201cUse an existing role\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><b>Step 5: Finally create a function<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><b><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test.png\" width=\"1231\" height=\"492\" alt=\"\" class=\"wp-image-4095 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test.png 1231w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test-980x392.png 980w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test-480x192.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1231px, 100vw\" \/><\/b><\/span><\/p>\n<p><b>Step 6: Go to your function dashboard.<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In this screen, you can see three tabs at the top:<\/span><span style=\"font-weight: 400;\"><br \/> <\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Configuration<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Permission<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Monitoring<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Configuration tab allows us to add triggers, edit or upload the function code, set environment variables, and so on.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Permission tab allows us to add different permissions to our lambda function. For example: If our function code writes data to DB, then we must provide the DB to write access to our function.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Monitoring tabs allow us to monitor our function status. For example the number of invocations, duration of function execution, maximum expensive execution, and so on.<\/span><\/p>\n<p><b>Step 7: Add Trigger<\/b><\/p>\n<p><span style=\"font-weight: 400;\"><br \/> <\/span><span style=\"font-weight: 400;\">We can add different triggering options to the lambda function. For example, We may trigger the function when objects are uploaded to S3, we also may trigger the function on API endpoints. For this, we can select different triggering services from the \u201cAdd trigger\u201d option.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/trigger.png\" width=\"1600\" height=\"871\" alt=\"\" class=\"wp-image-4096 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/trigger.png 1600w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/trigger-1280x697.png 1280w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/trigger-980x533.png 980w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/trigger-480x261.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) and (max-width: 1280px) 1280px, (min-width: 1281px) 1600px, 100vw\" \/><\/span><\/p>\n<p><b>Step8: Uploading\/Creating the Function Code<\/b><\/p>\n<p><span style=\"font-weight: 400;\">This is the main function code. Lambda dashboard provides an inline editor to write code from scratch. We can choose different runtimes like Node.js, python and many more. Also, also can zip our code and upload it directly from the option \u201cCode entry type\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We can write the function code inside the index.js file if we choose an option \u201cEdit code inline\u201d. The function code inside the handler block is similar to the normal javascript function and we can modify as per our need.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function-code.png\" width=\"1077\" height=\"369\" alt=\"\" class=\"wp-image-4097 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function-code.png 1077w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function-code-980x336.png 980w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/function-code-480x164.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1077px, 100vw\" \/><\/span><\/p>\n<p><b>Step 9: Add Environment variables<\/b><\/p>\n<p><span style=\"font-weight: 400;\">We can add different environment variables through this screen. We can set DB variables, AccessID, Secret key as environment variables as per our use.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/env-variables.png\" width=\"847\" height=\"445\" alt=\"\" class=\"wp-image-4098 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/env-variables.png 847w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/env-variables-480x252.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 847px, 100vw\" \/><\/span><\/p>\n<p><b>Step 10: Add Tags\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">A tag is a label that you assign to an AWS resource. Each tag consists of a key and an optional value. You can use tags to search and filter your resources or track your AWS costs.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/manage-tags.png\" width=\"823\" height=\"369\" alt=\"\" class=\"wp-image-4099 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/manage-tags.png 823w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/manage-tags-480x215.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 823px, 100vw\" \/><\/span><\/p>\n<p><b>Step 11: Editing of Basic Environment Settings<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The complexity level of our function depends upon our use case. In case if our function is CPU incentive or needs large memory we can adjust memory setting and estimated time of execution from this screen.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Memory settings can be adjusted through the slider.\u00a0<\/span><span style=\"font-weight: 400;\"><br \/> <b>Note: <\/b>Pricing of the Lambda function is done in the nearest 100ms. For example: If our function code runs for 108ms we should pay the cost of 200ms. So, shorter execution time, cheaper is the pricing.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/edit-settings.png\" width=\"819\" height=\"496\" alt=\"\" class=\"wp-image-4100 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/edit-settings.png 819w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/edit-settings-480x291.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 819px, 100vw\" \/><\/span><\/p>\n<p><b>Step 12: Creating a test function.<\/b><\/p>\n<p><span style=\"font-weight: 400;\">We also can execute our function through test events. We can simulate different event triggers by creating test events. For this, we can simply choose the \u201cConfigure test events\u201d option.<\/span><\/p>\n<p><b>Note<\/b><span>: We also can create other advanced triggering events using event templates.\u00a0<\/span><\/p>\n<p><span>For example, We can use S3 PUT event templates to simulate an event which is called when an object is created in any S3 objects.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/blog-test.png\" width=\"1600\" height=\"533\" alt=\"\" class=\"wp-image-4101 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/blog-test.png 1600w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/blog-test-1280x426.png 1280w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/blog-test-980x326.png 980w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/blog-test-480x160.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) and (max-width: 1280px) 1280px, (min-width: 1281px) 1600px, 100vw\" \/><\/span><\/p>\n<p><span style=\"font-weight: 400;\">We can provide a test event name and different test inputs to the lambda function as keys\/values to JSON objects and click on the \u201cCreate\u201d button.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test-event.png\" width=\"1600\" height=\"750\" alt=\"\" class=\"wp-image-4102 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test-event.png 1600w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test-event-1280x600.png 1280w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test-event-980x459.png 980w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/test-event-480x225.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) and (max-width: 1280px) 1280px, (min-width: 1281px) 1600px, 100vw\" \/><\/span><\/p>\n<p><b>Step 13: Testing the lambda function.<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Upon successful creation of the test event, we can execute our lambda function by simply clicking on the Test button as shown below.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" src=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/blog-test1.png\" width=\"512\" height=\"279\" alt=\"\" class=\"wp-image-4103 alignnone size-full\" srcset=\"https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/blog-test1.png 512w, https:\/\/www.genesesolution.com\/bd\/wp-content\/uploads\/sites\/4\/2020\/06\/blog-test1-480x262.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 512px, 100vw\" \/><\/span><\/p>\n<p><span style=\"font-weight: 400;\">And we also can view the execution results of our lambda function. Along with the function logs\/outputs, we also get different function meta information like time consumed for execution, memory consumption and many more. With such information, we can adjust our environment parameters for function optimization.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">All in all, the session was a fruitful one with the attending officials showing great interest in implementing the ideas to develop and retain talents in our country Nepal. In a nutshell, the webinar was a complete success as the response from the event was overwhelming with enthusiastic participants enrolled and was able to attract the attendees of varied career levels and was commended as fruitful by most of the attendees. Lastly, one major thing that makes the webinar more exciting and fruitful was participants were very interactive and the intercommunication between the participants and the facilitators was very smooth and effective which resulted in a great impact on learning for all the attendees.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><b>Video (Getting Started with AWS Lambda using Node JS)<\/b><\/span>\u00a0<\/p>\n[\/et_pb_text][et_pb_video src=&#8221;https:\/\/youtu.be\/RECRAXgecw0&#8243; _builder_version=&#8221;4.4.6&#8243;][\/et_pb_video][\/et_pb_column_inner][\/et_pb_row_inner][\/et_pb_column][et_pb_column type=&#8221;1_4&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_sidebar area=&#8221;sidebar-1&#8243; _builder_version=&#8221;3.15&#8243;][\/et_pb_sidebar][\/et_pb_column][\/et_pb_section]\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":191,"featured_media":4078,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","_links_to":"","_links_to_target":""},"categories":[70,76,80],"tags":[17,61,97],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Getting Started with AWS Lambda using Node JS<\/title>\n<meta name=\"description\" content=\"A webinar and demo session on Getting Started with AWS Lambda using Node JS was held on 15th May 2020, Friday starting from 5:00 pm to 7:00 pm NPT.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AWS Machine Learning Services\" \/>\n<meta property=\"og:description\" content=\"A webinar and demo session on AWS Machine Learning service that lets developers working with Amazon Web Services add image analysis to their applications.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/\" \/>\n<meta property=\"og:site_name\" content=\"Genese Solution Bangladesh\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-04T06:11:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-26T11:54:28+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"AWS Machine Learning Services\" \/>\n<meta name=\"twitter:description\" content=\"A webinar and demo session on AWS Machine Learning service that lets developers working with Amazon Web Services add image analysis to their applications.\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dipak Prasad Poudel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.genesesolution.com\/bd\/#website\",\"url\":\"https:\/\/www.genesesolution.com\/bd\/\",\"name\":\"Genese Solution Bangladesh\",\"description\":\"Creating you the best\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.genesesolution.com\/bd\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#webpage\",\"url\":\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/\",\"name\":\"Getting Started with AWS Lambda using Node JS\",\"isPartOf\":{\"@id\":\"https:\/\/www.genesesolution.com\/bd\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#primaryimage\"},\"datePublished\":\"2020-06-04T06:11:42+00:00\",\"dateModified\":\"2021-08-26T11:54:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.genesesolution.com\/bd\/#\/schema\/person\/263372dbc2517a9f0fda0cd7f9eb4c09\"},\"description\":\"A webinar and demo session on Getting Started with AWS Lambda using Node JS was held on 15th May 2020, Friday starting from 5:00 pm to 7:00 pm NPT.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.genesesolution.com\/bd\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Getting Started with AWS Lambda using Node JS\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.genesesolution.com\/bd\/#\/schema\/person\/263372dbc2517a9f0fda0cd7f9eb4c09\",\"name\":\"Dipak Prasad Poudel\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.genesesolution.com\/bd\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/14aafeb757e5efbe940bf602e30c1fc8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/14aafeb757e5efbe940bf602e30c1fc8?s=96&d=mm&r=g\",\"caption\":\"Dipak Prasad Poudel\"},\"url\":\"https:\/\/www.genesesolution.com\/bd\/blog\/author\/deepak\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting Started with AWS Lambda using Node JS","description":"A webinar and demo session on Getting Started with AWS Lambda using Node JS was held on 15th May 2020, Friday starting from 5:00 pm to 7:00 pm NPT.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/","og_locale":"en_US","og_type":"article","og_title":"AWS Machine Learning Services","og_description":"A webinar and demo session on AWS Machine Learning service that lets developers working with Amazon Web Services add image analysis to their applications.","og_url":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/","og_site_name":"Genese Solution Bangladesh","article_published_time":"2020-06-04T06:11:42+00:00","article_modified_time":"2021-08-26T11:54:28+00:00","twitter_card":"summary_large_image","twitter_title":"AWS Machine Learning Services","twitter_description":"A webinar and demo session on AWS Machine Learning service that lets developers working with Amazon Web Services add image analysis to their applications.","twitter_misc":{"Written by":"Dipak Prasad Poudel","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.genesesolution.com\/bd\/#website","url":"https:\/\/www.genesesolution.com\/bd\/","name":"Genese Solution Bangladesh","description":"Creating you the best","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.genesesolution.com\/bd\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#primaryimage","inLanguage":"en-US","url":"","contentUrl":""},{"@type":"WebPage","@id":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#webpage","url":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/","name":"Getting Started with AWS Lambda using Node JS","isPartOf":{"@id":"https:\/\/www.genesesolution.com\/bd\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#primaryimage"},"datePublished":"2020-06-04T06:11:42+00:00","dateModified":"2021-08-26T11:54:28+00:00","author":{"@id":"https:\/\/www.genesesolution.com\/bd\/#\/schema\/person\/263372dbc2517a9f0fda0cd7f9eb4c09"},"description":"A webinar and demo session on Getting Started with AWS Lambda using Node JS was held on 15th May 2020, Friday starting from 5:00 pm to 7:00 pm NPT.","breadcrumb":{"@id":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.genesesolution.com\/bd\/blog\/getting-started-with-aws-lambda-using-node-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.genesesolution.com\/bd\/"},{"@type":"ListItem","position":2,"name":"Getting Started with AWS Lambda using Node JS"}]},{"@type":"Person","@id":"https:\/\/www.genesesolution.com\/bd\/#\/schema\/person\/263372dbc2517a9f0fda0cd7f9eb4c09","name":"Dipak Prasad Poudel","image":{"@type":"ImageObject","@id":"https:\/\/www.genesesolution.com\/bd\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/14aafeb757e5efbe940bf602e30c1fc8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/14aafeb757e5efbe940bf602e30c1fc8?s=96&d=mm&r=g","caption":"Dipak Prasad Poudel"},"url":"https:\/\/www.genesesolution.com\/bd\/blog\/author\/deepak\/"}]}},"_links":{"self":[{"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/posts\/4077"}],"collection":[{"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/users\/191"}],"replies":[{"embeddable":true,"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/comments?post=4077"}],"version-history":[{"count":7,"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/posts\/4077\/revisions"}],"predecessor-version":[{"id":6446,"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/posts\/4077\/revisions\/6446"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/media\/4078"}],"wp:attachment":[{"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/media?parent=4077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/categories?post=4077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.genesesolution.com\/bd\/wp-json\/wp\/v2\/tags?post=4077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}