1
00:00:00,390 --> 00:00:07,360
In this video, we are going to update a lambda function code using the commands.

2
00:00:08,040 --> 00:00:13,440
So in this video we have several steps to update, deploy and invoke lambda function.

3
00:00:13,890 --> 00:00:16,620
Let me right time step by step to do this.

4
00:00:16,620 --> 00:00:23,400
The first one is the lambda function code with the updated one and the second step is zip function code

5
00:00:23,550 --> 00:00:30,720
and the third step is update lambda function with to select commands and the last step is invoke updated

6
00:00:30,720 --> 00:00:33,720
lambda function with the commands.

7
00:00:34,170 --> 00:00:36,870
Okay, let's get start and follow these steps.

8
00:00:36,870 --> 00:00:44,250
Please open the Visual Studio code and create a new folder and we will follow these four steps in this

9
00:00:44,250 --> 00:00:44,880
video.

10
00:00:45,030 --> 00:00:48,510
So the first step is develop lambda function code.

11
00:00:48,540 --> 00:00:56,220
In order to do that, I'm going to create a new file which is the index that JS file and in the Indexer

12
00:00:56,220 --> 00:01:04,410
JS file, I'm going to update our existing code if you remember that our existing code only logging

13
00:01:04,410 --> 00:01:07,560
incoming event and return back to the hello world.

14
00:01:07,560 --> 00:01:15,540
But this time I'm going to get even that number one and number two and multiply these numbers and return

15
00:01:15,540 --> 00:01:19,470
back to the total number in the body of the response of these methods.

16
00:01:19,530 --> 00:01:21,690
So this is the updated function.

17
00:01:21,690 --> 00:01:28,560
In our example, we basically expect number one and number two parameters into incoming event, JSON

18
00:01:28,560 --> 00:01:34,590
object and return back the calculated result to these numbers in the body of the response.

19
00:01:35,250 --> 00:01:35,820
Okay.

20
00:01:35,820 --> 00:01:39,120
Now I'm going to update a lambda function code.

21
00:01:39,120 --> 00:01:45,930
So here you can see that we are going to second step, which is the zip function code.

22
00:01:45,960 --> 00:01:53,340
In order to zip our function code, we have three ways we can use this zip or compress archive commands

23
00:01:53,340 --> 00:02:01,320
or we can do it manually for archiving our updated code and following the second one.

24
00:02:01,320 --> 00:02:06,780
Since we have only one index file, I can use compress archive file.

25
00:02:06,810 --> 00:02:10,500
In order to do that, I'm going to open a new terminal and.

26
00:02:11,320 --> 00:02:14,380
Go to record lectures.

27
00:02:17,020 --> 00:02:22,370
And now I'm going to compress archive command indexes as a function of zip.

28
00:02:22,400 --> 00:02:24,770
Hit the enter and see that function.

29
00:02:24,770 --> 00:02:27,110
That zip is created successfully.

30
00:02:27,350 --> 00:02:35,330
And now in the third step we are going to update lambda function with using a select commons for that

31
00:02:35,330 --> 00:02:36,070
purpose.

32
00:02:36,080 --> 00:02:41,580
Update function code in here and here you can find the required a SQL Command.

33
00:02:41,600 --> 00:02:48,710
This time I'm going to use a Lambda Update function code with passing function name and zip file archive

34
00:02:48,710 --> 00:02:49,310
file.

35
00:02:49,370 --> 00:02:50,060
Okay.

36
00:02:50,120 --> 00:02:57,590
Please copy this line of code and paste in here and this will be update my existing code.

37
00:02:58,580 --> 00:03:05,720
Here you can see the result is successfully updated and now we can check the update code from the management

38
00:03:05,720 --> 00:03:10,070
console to verify our change reflected on lambda function code or not.

39
00:03:10,100 --> 00:03:13,280
Please go to lambda functions on management console.

40
00:03:13,310 --> 00:03:16,730
Open the my function to and come to code window.

41
00:03:16,910 --> 00:03:18,800
You can see that in here.

42
00:03:19,430 --> 00:03:27,250
We have updated code is deployed successfully, so we have verified our function is updated successfully.

43
00:03:27,260 --> 00:03:31,820
Now the last step is invoke our updated lambda function with the CLI.

44
00:03:31,820 --> 00:03:38,990
So if you scroll down under the text file now I'm going to invoke our updated lambda function for that

45
00:03:38,990 --> 00:03:39,530
purpose.

46
00:03:39,530 --> 00:03:47,720
First of all, it is good to create event JSON file, so let me create even JSON file under the lecture

47
00:03:47,720 --> 00:03:51,680
52 and under the event JSON file.

48
00:03:51,680 --> 00:03:55,520
This time I'm going to create a two parameters.

49
00:03:55,520 --> 00:04:01,460
The first one is number one and one is number two, because our function is required, these number

50
00:04:01,460 --> 00:04:05,840
one and number two in order to multiply and return back to body statement.

51
00:04:05,840 --> 00:04:11,390
So that's why I have created this JSON object, which including the number one and number two.

52
00:04:11,630 --> 00:04:17,870
So this is the numbers, random numbers that you can define in here after we have created the event

53
00:04:17,870 --> 00:04:23,360
JSON file, now we can ready for the invoke our lambda function, which is even just an object.

54
00:04:23,360 --> 00:04:29,660
If you scroll down you can see and find these lambda IMO command in order to invoke our function with

55
00:04:29,660 --> 00:04:31,020
these events.

56
00:04:31,120 --> 00:04:38,840
An object in the same directory you maybe you remember we should specify the cli binary format and pasting

57
00:04:38,840 --> 00:04:40,730
the payload as a file of the event.

58
00:04:40,730 --> 00:04:41,540
JSON file.

59
00:04:41,570 --> 00:04:45,500
Copy this command and come to the command window.

60
00:04:46,360 --> 00:04:49,060
And paste in here and hit enter.

61
00:04:50,900 --> 00:04:53,520
So as you can see, that status quo is 200.

62
00:04:53,540 --> 00:04:58,310
So that means we have invoked synchronously and successfully our function.

63
00:04:58,400 --> 00:05:01,220
In order to see the result, we should check the response.

64
00:05:01,220 --> 00:05:08,390
That JSON object response is created under this lecture folder and open this file and see the response.

65
00:05:08,390 --> 00:05:16,190
So code is 280 is the description is said that the total is of three and four is 12.

66
00:05:16,190 --> 00:05:20,000
So that means multiply successfully and return back to successfully.

67
00:05:20,090 --> 00:05:25,490
This was multiply function and we have multiply with the number one and number two and calculate the

68
00:05:25,490 --> 00:05:26,360
total number.

69
00:05:26,450 --> 00:05:33,800
We can also verify lambda execution from the cloud which logs if you open our management console, go

70
00:05:33,800 --> 00:05:36,740
to monitor and we include cloud logs.

71
00:05:39,060 --> 00:05:42,510
We can verify from the latest log stream.

72
00:05:42,570 --> 00:05:49,410
You can see that our incoming event is number one and number two, and we return back to the information

73
00:05:49,410 --> 00:05:51,450
with multiplying these two numbers.

74
00:05:51,870 --> 00:05:58,920
As you can see that we have followed and successfully finished these four steps, the will of Lambda

75
00:05:58,920 --> 00:06:04,080
Code to update one zip function code, update lambda function code with a double click command.

76
00:06:04,110 --> 00:06:09,090
And lastly, we invoke the updated Lambda function code with using a double click commands.
