1
00:00:00,180 --> 00:00:05,550
In this video, we are going to deploy product lambda function with uploading zip file.

2
00:00:05,700 --> 00:00:10,470
First of all, we should start with to compress and zip our Node.js lambda function.

3
00:00:10,620 --> 00:00:17,730
As you remember that we are developing lambda function with Node.js 16 version and using a basic JavaScript

4
00:00:17,730 --> 00:00:20,370
version three with six standards.

5
00:00:20,700 --> 00:00:27,240
So since we use Dynamo DB SDK package, we should compress and zip the whole Node.js project as a lambda

6
00:00:27,240 --> 00:00:27,900
function.

7
00:00:28,200 --> 00:00:30,540
So please open the pseudocode.

8
00:00:31,810 --> 00:00:38,060
So please save all these indexes and save all files and come to this lecture folder, which is the our

9
00:00:38,110 --> 00:00:39,330
Node.js application.

10
00:00:39,340 --> 00:00:47,220
If you right click and reveal in Explorer, we can go to the function for the details and select all.

11
00:00:47,230 --> 00:00:54,340
Now I don't want events so the rest of the files is required or Node.js application, which will be

12
00:00:54,340 --> 00:00:57,520
the lambda function, which is the product microservices.

13
00:00:57,670 --> 00:01:03,460
For that purpose, I'm going to right click send to compress zip file.

14
00:01:06,570 --> 00:01:08,160
So this takes some time.

15
00:01:10,270 --> 00:01:15,130
After that, we can give the name as a product function.

16
00:01:18,500 --> 00:01:25,040
And please verify that if you double click this zip file, you can see exactly the same folder structure

17
00:01:25,040 --> 00:01:26,980
into our lecture folder.

18
00:01:26,990 --> 00:01:31,760
See that we have node modules, index case file in the same folder structure.

19
00:01:31,760 --> 00:01:35,510
So we have verified that the folder structure is same.

20
00:01:35,540 --> 00:01:38,820
Now it is time to deploy our lambda function for that purpose.

21
00:01:38,840 --> 00:01:45,860
Open the console, go to product function and click the upload from and upload from a zip file and click

22
00:01:45,860 --> 00:01:52,670
the upload button or click the upload button and go to location of our product function and click the

23
00:01:52,700 --> 00:01:53,570
open button.

24
00:01:54,050 --> 00:01:59,090
As you can see that we have to make a white product function, zip file and click the save operation.

25
00:01:59,090 --> 00:02:04,390
By the way, in Lambda section, we learned that all these operations can be done with using a double

26
00:02:04,550 --> 00:02:06,650
click commands to make it simpler.

27
00:02:06,650 --> 00:02:13,190
I'm using a management console when deploying our lambda function, so it takes some time and after

28
00:02:13,190 --> 00:02:20,120
that if you scroll down and come to code part, you can see that we have exactly the same folder structure

29
00:02:20,120 --> 00:02:21,590
into our lambda function.

30
00:02:21,590 --> 00:02:27,800
We have a product function and under the production function we have a indexes which including all our

31
00:02:27,800 --> 00:02:31,100
codes which we develop in the application.

32
00:02:31,100 --> 00:02:37,130
So when we give our codes in the case management console, we can see some warning message.

33
00:02:37,130 --> 00:02:43,700
So it is good practice to check your codes from the measurement console and do see exceptions in here.

34
00:02:43,700 --> 00:02:48,110
So as you can see that we forgot to set the error as a definition.

35
00:02:48,110 --> 00:02:53,270
So instead of we are using the error in here, we should change these as a E.

36
00:02:53,300 --> 00:02:59,120
So if you scroll down you can see another exception which is the UUID viewport.

37
00:02:59,150 --> 00:03:04,670
We forgot to import this UUID library into the beginning of our import statement.

38
00:03:04,670 --> 00:03:09,080
So these are the very good practice to understand the potential exceptions.

39
00:03:09,080 --> 00:03:12,980
So please go back to our pseudocode code and fix these errors.

40
00:03:12,980 --> 00:03:17,570
Now first of all, we should check the all catch blocks if you scroll down.

41
00:03:18,540 --> 00:03:23,270
Take the catch block and verify that you are using the same variable.

42
00:03:23,280 --> 00:03:25,970
And if you scroll down, check the cage statement.

43
00:03:25,980 --> 00:03:32,940
Yes, we should change this e and save these index file and check this cage below.

44
00:03:34,750 --> 00:03:37,120
And everything seems okay for now.

45
00:03:37,150 --> 00:03:39,970
The only problem is the first method.

46
00:03:40,480 --> 00:03:47,140
After checking to catch method, we have also required to fix the great product method.

47
00:03:47,170 --> 00:03:52,280
As you can see that in the great product method we are using UUID Library.

48
00:03:52,300 --> 00:03:57,770
If you come here and click the control space, we should import required packages for that purpose.

49
00:03:57,790 --> 00:04:00,550
I'm going to open the API package of the UUID.

50
00:04:00,580 --> 00:04:06,490
If you scroll down, you can see that this is showing how we should import these statements.

51
00:04:06,520 --> 00:04:12,130
So let me go on top of the page and paste to UUID Library.

52
00:04:12,340 --> 00:04:12,720
Okay.

53
00:04:12,730 --> 00:04:19,720
If you go to the create product and this time we can see the UUID library is working fine and it is

54
00:04:19,720 --> 00:04:20,920
important successfully.

55
00:04:21,010 --> 00:04:25,230
And we have one important bug that we should fix in this place.

56
00:04:25,240 --> 00:04:31,510
So as you can see that we have switch case statement and every case should a break statement.

57
00:04:31,510 --> 00:04:37,640
Otherwise it will break it will don't break operation and continue the other case statement.

58
00:04:37,660 --> 00:04:41,530
So as you can see that in the case statement, we don't have any break.

59
00:04:41,530 --> 00:04:48,610
So please add the break statement into the gasket and make sure that every case statement has a break

60
00:04:48,610 --> 00:04:52,540
statement that will be break the code and continue the return statement.

61
00:04:52,620 --> 00:04:52,890
Okay.

62
00:04:52,900 --> 00:04:59,620
After making this change, please save this index case file and follow the same steps when we are deploying

63
00:04:59,620 --> 00:05:00,580
lambda function.

64
00:05:00,730 --> 00:05:02,880
Right click reveal in explorer.

65
00:05:02,890 --> 00:05:04,210
Go to folder structure.

66
00:05:04,210 --> 00:05:09,250
Select all except the events folder and right click.

67
00:05:09,990 --> 00:05:13,050
All these folders and sent to Z file.

68
00:05:13,050 --> 00:05:17,970
Let me remove the function and we are going to make it again.

69
00:05:18,300 --> 00:05:25,860
Remove events right click send to compress zip file, give the name as a product function and go back

70
00:05:25,860 --> 00:05:31,440
to our lambda function and come to upload the zip file.

71
00:05:31,710 --> 00:05:35,820
Click the upload button and click the product function and click the save button.

72
00:05:37,340 --> 00:05:38,660
After the deployment.

73
00:05:38,660 --> 00:05:43,730
That's all we've again and see that this time we don't have any warning or exception.

74
00:05:43,730 --> 00:05:46,390
So that means we have deployed successfully.

75
00:05:46,430 --> 00:05:48,710
And also we can check the package JSON file.

76
00:05:48,710 --> 00:05:56,860
We have dependencies correctly and we are verified that the whole folder structure is exactly the same.

77
00:05:56,870 --> 00:06:01,970
What we have zipped in the zip file, we can verify from the product function.

78
00:06:01,970 --> 00:06:07,610
Okay, that means we have successfully upload our codes and now it is time to test our function.
