In this video, we are going to start to develop our lambda function.
But before that it is good to understand how Amazon is treated with the lambda function and what is
the event JSON for that purpose.
We can go to a lambda function and if you come here come to test.
But we can remember that.
We can see the templates.
If you copy and open this dropdown and search for the S3, you can see the S3, put example, even JSON
object in the template of the test file into the mission console.
Here you can see the example evaluation.
So that means this comes from the records array and every record has these kind of attributes that we
can get these object key size and all these information about Amazon S3 bucket name and the object name.
So this is the example event JSON format that we can develop our lambda function.
But I would like to get the exactly right event JSON file from our S3 bucket.
For that purpose.
I'm going to trigger this S3 upload object from uploading any object into S3 and see the lambda function
logs that invoke from the asynchronously from the S3.
Please go to a three page and I'm going to upload an object click to upload and add file, go to section
folder.
And if you go to record section folder, you can see the index HTML file.
I am going to upload the index HTML file.
So if you click the upload button, this should trigger or a lambda function asynchronously.
So upload succeeded.
If you come back to our lambda function and go to monitor and we logs in the cloud watch logs, we should
see the invocation log.
Yes, it comes for the invocation logs.
If you click this incoming event, JSON and copy this JSON.
And past the hour.
We used to do a code lecture folder.
I have created a separate lecture folder and add the stream JSON file.
If you copy and paste in here and remove the first line and save this file, we can reach the exact
same and correct incoming event JSON from the S3 to Lambda function.
Here we have a records array and we only have one record and in the S3 section we can get the bucket
name principal Aaron and also object.
It is in here as you can see that we have upload indexed html file and this is the size and the other
attribute and informations.
Okay, very good.
So now we can start developing our lambda function with this incoming S3 limitation file.
So basically we will get these information about S3 and write down into the Dynamo DB table.
I'm going to write the bucket name and also object name into Dynamo DB table.
That means in the lambda function we will have to interaction.
So we will get the bucket name and detail from the S3 and after that write Dynamo DB table.
That's why in the permission top we have these permissions into our execution role.
If you come back to our lambda function and come to configuration and permission, you can see that
we have both dynamic DB and S3 requirement permissions because we will read the details of the S3 bucket
from Amazon S3 and write these information into the dynamic DB table.
Okay.
How we can interact with these resources.
Of course, we will use the Amazon SDK JavaScript version three libraries.
So let's start to developing.