In this video, we are going to deploy product lambda function with uploading zip file.
First of all, we should start with to compress and zip our Node.js lambda function.
As you remember that we are developing lambda function with Node.js 16 version and using a basic JavaScript
version three with six standards.
So since we use Dynamo DB SDK package, we should compress and zip the whole Node.js project as a lambda
function.
So please open the pseudocode.
So please save all these indexes and save all files and come to this lecture folder, which is the our
Node.js application.
If you right click and reveal in Explorer, we can go to the function for the details and select all.
Now I don't want events so the rest of the files is required or Node.js application, which will be
the lambda function, which is the product microservices.
For that purpose, I'm going to right click send to compress zip file.
So this takes some time.
After that, we can give the name as a product function.
And please verify that if you double click this zip file, you can see exactly the same folder structure
into our lecture folder.
See that we have node modules, index case file in the same folder structure.
So we have verified that the folder structure is same.
Now it is time to deploy our lambda function for that purpose.
Open the console, go to product function and click the upload from and upload from a zip file and click
the upload button or click the upload button and go to location of our product function and click the
open button.
As you can see that we have to make a white product function, zip file and click the save operation.
By the way, in Lambda section, we learned that all these operations can be done with using a double
click commands to make it simpler.
I'm using a management console when deploying our lambda function, so it takes some time and after
that if you scroll down and come to code part, you can see that we have exactly the same folder structure
into our lambda function.
We have a product function and under the production function we have a indexes which including all our
codes which we develop in the application.
So when we give our codes in the case management console, we can see some warning message.
So it is good practice to check your codes from the measurement console and do see exceptions in here.
So as you can see that we forgot to set the error as a definition.
So instead of we are using the error in here, we should change these as a E.
So if you scroll down you can see another exception which is the UUID viewport.
We forgot to import this UUID library into the beginning of our import statement.
So these are the very good practice to understand the potential exceptions.
So please go back to our pseudocode code and fix these errors.
Now first of all, we should check the all catch blocks if you scroll down.
Take the catch block and verify that you are using the same variable.
And if you scroll down, check the cage statement.
Yes, we should change this e and save these index file and check this cage below.
And everything seems okay for now.
The only problem is the first method.
After checking to catch method, we have also required to fix the great product method.
As you can see that in the great product method we are using UUID Library.
If you come here and click the control space, we should import required packages for that purpose.
I'm going to open the API package of the UUID.
If you scroll down, you can see that this is showing how we should import these statements.
So let me go on top of the page and paste to UUID Library.
Okay.
If you go to the create product and this time we can see the UUID library is working fine and it is
important successfully.
And we have one important bug that we should fix in this place.
So as you can see that we have switch case statement and every case should a break statement.
Otherwise it will break it will don't break operation and continue the other case statement.
So as you can see that in the case statement, we don't have any break.
So please add the break statement into the gasket and make sure that every case statement has a break
statement that will be break the code and continue the return statement.
Okay.
After making this change, please save this index case file and follow the same steps when we are deploying
lambda function.
Right click reveal in explorer.
Go to folder structure.
Select all except the events folder and right click.
All these folders and sent to Z file.
Let me remove the function and we are going to make it again.
Remove events right click send to compress zip file, give the name as a product function and go back
to our lambda function and come to upload the zip file.
Click the upload button and click the product function and click the save button.
After the deployment.
That's all we've again and see that this time we don't have any warning or exception.
So that means we have deployed successfully.
And also we can check the package JSON file.
We have dependencies correctly and we are verified that the whole folder structure is exactly the same.
What we have zipped in the zip file, we can verify from the product function.
Okay, that means we have successfully upload our codes and now it is time to test our function.