In this video, we are going to update a lambda function code using the commands.
So in this video we have several steps to update, deploy and invoke lambda function.
Let me right time step by step to do this.
The first one is the lambda function code with the updated one and the second step is zip function code
and the third step is update lambda function with to select commands and the last step is invoke updated
lambda function with the commands.
Okay, let's get start and follow these steps.
Please open the Visual Studio code and create a new folder and we will follow these four steps in this
video.
So the first step is develop lambda function code.
In order to do that, I'm going to create a new file which is the index that JS file and in the Indexer
JS file, I'm going to update our existing code if you remember that our existing code only logging
incoming event and return back to the hello world.
But this time I'm going to get even that number one and number two and multiply these numbers and return
back to the total number in the body of the response of these methods.
So this is the updated function.
In our example, we basically expect number one and number two parameters into incoming event, JSON
object and return back the calculated result to these numbers in the body of the response.
Okay.
Now I'm going to update a lambda function code.
So here you can see that we are going to second step, which is the zip function code.
In order to zip our function code, we have three ways we can use this zip or compress archive commands
or we can do it manually for archiving our updated code and following the second one.
Since we have only one index file, I can use compress archive file.
In order to do that, I'm going to open a new terminal and.
Go to record lectures.
And now I'm going to compress archive command indexes as a function of zip.
Hit the enter and see that function.
That zip is created successfully.
And now in the third step we are going to update lambda function with using a select commons for that
purpose.
Update function code in here and here you can find the required a SQL Command.
This time I'm going to use a Lambda Update function code with passing function name and zip file archive
file.
Okay.
Please copy this line of code and paste in here and this will be update my existing code.
Here you can see the result is successfully updated and now we can check the update code from the management
console to verify our change reflected on lambda function code or not.
Please go to lambda functions on management console.
Open the my function to and come to code window.
You can see that in here.
We have updated code is deployed successfully, so we have verified our function is updated successfully.
Now the last step is invoke our updated lambda function with the CLI.
So if you scroll down under the text file now I'm going to invoke our updated lambda function for that
purpose.
First of all, it is good to create event JSON file, so let me create even JSON file under the lecture
52 and under the event JSON file.
This time I'm going to create a two parameters.
The first one is number one and one is number two, because our function is required, these number
one and number two in order to multiply and return back to body statement.
So that's why I have created this JSON object, which including the number one and number two.
So this is the numbers, random numbers that you can define in here after we have created the event
JSON file, now we can ready for the invoke our lambda function, which is even just an object.
If you scroll down you can see and find these lambda IMO command in order to invoke our function with
these events.
An object in the same directory you maybe you remember we should specify the cli binary format and pasting
the payload as a file of the event.
JSON file.
Copy this command and come to the command window.
And paste in here and hit enter.
So as you can see, that status quo is 200.
So that means we have invoked synchronously and successfully our function.
In order to see the result, we should check the response.
That JSON object response is created under this lecture folder and open this file and see the response.
So code is 280 is the description is said that the total is of three and four is 12.
So that means multiply successfully and return back to successfully.
This was multiply function and we have multiply with the number one and number two and calculate the
total number.
We can also verify lambda execution from the cloud which logs if you open our management console, go
to monitor and we include cloud logs.
We can verify from the latest log stream.
You can see that our incoming event is number one and number two, and we return back to the information
with multiplying these two numbers.
As you can see that we have followed and successfully finished these four steps, the will of Lambda
Code to update one zip function code, update lambda function code with a double click command.
And lastly, we invoke the updated Lambda function code with using a double click commands.