1
00:00:00,390 --> 00:00:06,390
In this video, we are going to develop a lambda function handle in Node.js.

2
00:00:07,060 --> 00:00:09,300
So we are in the second step.

3
00:00:09,310 --> 00:00:13,870
We have created execution role and now we are going to create a function code that will function code.

4
00:00:14,350 --> 00:00:15,470
Okay, let's get started.

5
00:00:15,490 --> 00:00:18,340
Please open the visual code and create a new lecture.

6
00:00:18,760 --> 00:00:24,610
And as you can see that before we creating this any section, we have created a separate lecture.

7
00:00:24,910 --> 00:00:31,420
Now we will use Node.js runtime for our lambda functions and it is required to 100 method that we will

8
00:00:31,420 --> 00:00:32,800
develop in this video.

9
00:00:32,890 --> 00:00:38,860
The lambda function handler is the method in our function code that processed the events incoming events.

10
00:00:38,860 --> 00:00:42,340
When our function is invoked, Lambda runs the handler method.

11
00:00:42,520 --> 00:00:48,670
So when the handler exits or returns a response, it becomes available to handle another event.

12
00:00:48,670 --> 00:00:52,990
So this is the basic execution principle for the lambda functions.

13
00:00:52,990 --> 00:00:56,770
For that purpose, I'm going to create a new file which is the index.

14
00:00:57,040 --> 00:01:01,600
JS This will be include our Lambda Handler code.

15
00:01:01,600 --> 00:01:05,470
So in these index JS we will develop basic Lambda Code.

16
00:01:05,500 --> 00:01:09,130
I'm going to developing our basic lambda code.

17
00:01:09,130 --> 00:01:17,140
You can see in here I have copy and paste for the export standard by this method name we are exporting

18
00:01:17,140 --> 00:01:23,890
the handle method and this will be getting event parameter for the incoming event and we basically lock

19
00:01:23,890 --> 00:01:27,160
these incoming events and after that we will return the response.

20
00:01:27,400 --> 00:01:28,690
Hello from Lambda.

21
00:01:29,500 --> 00:01:36,010
Okay, so this is the basic lambda code that looks to incoming event and return success response with

22
00:01:36,010 --> 00:01:37,000
the hello message.

23
00:01:37,120 --> 00:01:43,300
Basically this example function log the contents and log the event, incoming event object and return

24
00:01:43,300 --> 00:01:47,020
back to the this string response as a body.

25
00:01:47,290 --> 00:01:50,430
And in our case our finding is indexed.

26
00:01:50,620 --> 00:01:54,250
JS And our method name is the 100 method.

27
00:01:54,250 --> 00:01:56,410
So this is the export standard.

28
00:01:56,410 --> 00:02:00,940
So the default values is this name in the console.

29
00:02:00,940 --> 00:02:04,210
Also we can see this index file and 100 method.

30
00:02:05,210 --> 00:02:09,050
So basically the runtime passes three arguments to the 100 method.

31
00:02:09,080 --> 00:02:15,900
The first parameters is event and event object, which contains the information from the invoker and

32
00:02:15,900 --> 00:02:16,820
the IMO capacities.

33
00:02:16,820 --> 00:02:23,990
Information is adjacent format string one invoke this function and the runtime is converts to this object.

34
00:02:24,200 --> 00:02:27,110
One Natively service is invoked our function.

35
00:02:27,110 --> 00:02:29,750
The event structure varies by the invoke or services.

36
00:02:29,750 --> 00:02:36,350
For example, this event object will be differentiate when it invokes from the Amazon S3 or API gateway.

37
00:02:36,380 --> 00:02:40,430
We will see these different events in Lambda function in the upcoming sections.

38
00:02:40,430 --> 00:02:47,390
But basically in this video we have developed our Lambda function code with the default code window

39
00:02:47,420 --> 00:02:53,900
and also you can check the default method from the our last created lambda function.

40
00:02:53,900 --> 00:02:59,870
If you open the my function and contact window, you can see that this is the default hundred method

41
00:02:59,870 --> 00:03:02,810
which is generated from the ADA is lambda.

42
00:03:02,810 --> 00:03:08,600
So we have using the same template for our newly created lambda function.
