1
00:00:00,150 --> 00:00:05,160
In this video, we are going to start to develop our lambda function.

2
00:00:05,160 --> 00:00:11,580
But before that it is good to understand how Amazon is treated with the lambda function and what is

3
00:00:11,580 --> 00:00:14,070
the event JSON for that purpose.

4
00:00:14,070 --> 00:00:19,230
We can go to a lambda function and if you come here come to test.

5
00:00:19,230 --> 00:00:20,970
But we can remember that.

6
00:00:20,970 --> 00:00:22,560
We can see the templates.

7
00:00:22,560 --> 00:00:31,230
If you copy and open this dropdown and search for the S3, you can see the S3, put example, even JSON

8
00:00:31,230 --> 00:00:36,210
object in the template of the test file into the mission console.

9
00:00:36,240 --> 00:00:38,610
Here you can see the example evaluation.

10
00:00:38,610 --> 00:00:45,360
So that means this comes from the records array and every record has these kind of attributes that we

11
00:00:45,360 --> 00:00:51,930
can get these object key size and all these information about Amazon S3 bucket name and the object name.

12
00:00:52,080 --> 00:00:56,310
So this is the example event JSON format that we can develop our lambda function.

13
00:00:56,310 --> 00:01:02,760
But I would like to get the exactly right event JSON file from our S3 bucket.

14
00:01:02,760 --> 00:01:03,810
For that purpose.

15
00:01:03,810 --> 00:01:11,490
I'm going to trigger this S3 upload object from uploading any object into S3 and see the lambda function

16
00:01:11,490 --> 00:01:16,050
logs that invoke from the asynchronously from the S3.

17
00:01:16,740 --> 00:01:24,180
Please go to a three page and I'm going to upload an object click to upload and add file, go to section

18
00:01:24,180 --> 00:01:24,870
folder.

19
00:01:25,020 --> 00:01:30,000
And if you go to record section folder, you can see the index HTML file.

20
00:01:30,000 --> 00:01:33,000
I am going to upload the index HTML file.

21
00:01:33,180 --> 00:01:39,660
So if you click the upload button, this should trigger or a lambda function asynchronously.

22
00:01:39,660 --> 00:01:41,460
So upload succeeded.

23
00:01:41,490 --> 00:01:49,050
If you come back to our lambda function and go to monitor and we logs in the cloud watch logs, we should

24
00:01:49,050 --> 00:01:51,600
see the invocation log.

25
00:01:51,630 --> 00:01:54,750
Yes, it comes for the invocation logs.

26
00:01:54,750 --> 00:01:59,340
If you click this incoming event, JSON and copy this JSON.

27
00:01:59,340 --> 00:02:00,870
And past the hour.

28
00:02:00,870 --> 00:02:02,940
We used to do a code lecture folder.

29
00:02:02,970 --> 00:02:07,740
I have created a separate lecture folder and add the stream JSON file.

30
00:02:07,770 --> 00:02:15,360
If you copy and paste in here and remove the first line and save this file, we can reach the exact

31
00:02:15,390 --> 00:02:19,980
same and correct incoming event JSON from the S3 to Lambda function.

32
00:02:19,980 --> 00:02:27,510
Here we have a records array and we only have one record and in the S3 section we can get the bucket

33
00:02:27,510 --> 00:02:30,540
name principal Aaron and also object.

34
00:02:30,540 --> 00:02:36,570
It is in here as you can see that we have upload indexed html file and this is the size and the other

35
00:02:36,570 --> 00:02:38,090
attribute and informations.

36
00:02:38,370 --> 00:02:39,360
Okay, very good.

37
00:02:39,450 --> 00:02:45,090
So now we can start developing our lambda function with this incoming S3 limitation file.

38
00:02:45,090 --> 00:02:50,940
So basically we will get these information about S3 and write down into the Dynamo DB table.

39
00:02:50,940 --> 00:02:54,960
I'm going to write the bucket name and also object name into Dynamo DB table.

40
00:02:54,990 --> 00:02:58,860
That means in the lambda function we will have to interaction.

41
00:02:58,980 --> 00:03:06,210
So we will get the bucket name and detail from the S3 and after that write Dynamo DB table.

42
00:03:06,210 --> 00:03:11,640
That's why in the permission top we have these permissions into our execution role.

43
00:03:11,670 --> 00:03:17,400
If you come back to our lambda function and come to configuration and permission, you can see that

44
00:03:17,400 --> 00:03:25,230
we have both dynamic DB and S3 requirement permissions because we will read the details of the S3 bucket

45
00:03:25,230 --> 00:03:29,940
from Amazon S3 and write these information into the dynamic DB table.

46
00:03:30,240 --> 00:03:30,600
Okay.

47
00:03:30,660 --> 00:03:33,240
How we can interact with these resources.

48
00:03:33,240 --> 00:03:37,920
Of course, we will use the Amazon SDK JavaScript version three libraries.

49
00:03:37,920 --> 00:03:39,540
So let's start to developing.
