1
00:00:00,390 --> 00:00:07,800
In this video, we are going to see how Amazon API Gateway triggered a Lambda with API Gateway Proxy

2
00:00:07,800 --> 00:00:08,430
events.

3
00:00:08,520 --> 00:00:15,030
So we will see example event JSON objects which is coming from API gateway to lambda function.

4
00:00:15,330 --> 00:00:16,680
This is very important step.

5
00:00:16,680 --> 00:00:21,930
Before starting to developing, we should understand incoming event structure from trigger resources

6
00:00:21,960 --> 00:00:23,580
of our lambda function.

7
00:00:23,820 --> 00:00:29,190
In this case, our product lambda function will trigger from the Amazon API gateway, which synchronously

8
00:00:29,370 --> 00:00:32,610
we have over the create infrastructure or API gateway.

9
00:00:32,610 --> 00:00:36,210
And now this will be triggered by our product microservices.

10
00:00:36,480 --> 00:00:41,020
Now let's find the event that triggered from the API gateway to lambda function.

11
00:00:41,040 --> 00:00:47,870
There are several ways to find this triggered event JSON object, but I would like to open our cloud

12
00:00:48,030 --> 00:00:50,770
logs from the product function.

13
00:00:50,790 --> 00:00:56,550
If you go to product function and go to Amazon Cloud Logs, you can see that you can find here.

14
00:00:56,550 --> 00:01:02,040
We have already triggered a lambda function from API Gateway.

15
00:01:02,040 --> 00:01:09,000
When we are invoke from the postman, you can see that is the get product post product, get buy ID

16
00:01:09,000 --> 00:01:12,270
product, put my ID product and delete my ID product.

17
00:01:12,420 --> 00:01:18,090
All invocation logs are stored Amazon logs and you can see the logs in here.

18
00:01:18,090 --> 00:01:22,500
For example, let's start with the first one, which is the gate product.

19
00:01:22,500 --> 00:01:26,010
And after that we sent the post product.

20
00:01:26,370 --> 00:01:28,980
And after that we have sent the.

21
00:01:29,820 --> 00:01:36,270
In here, you can see the get product, buy ID and here you can see the put product by ID.

22
00:01:36,270 --> 00:01:39,600
And lastly, you can see the delayed product by ID.

23
00:01:39,870 --> 00:01:44,640
I have copied all these source and paste into our project.

24
00:01:44,640 --> 00:01:51,210
You can see that this is our product project folder structure and I have create events folder and in

25
00:01:51,210 --> 00:01:58,800
this folder I have stored all incoming JSON files from Amazon API, Amazon API gateway to the lambda

26
00:01:58,800 --> 00:01:59,460
function.

27
00:01:59,490 --> 00:02:06,990
Here you can see the get products, you can see the get by ID for example, in here the parameters are

28
00:02:06,990 --> 00:02:13,140
different and if you scroll down you can see the parameters ID in here and here you can see the post

29
00:02:13,140 --> 00:02:13,890
product.

30
00:02:13,890 --> 00:02:17,550
If you scroll down, you can find the body information.

31
00:02:17,550 --> 00:02:25,290
This is the post product that will create any product item in product dynamo DB table and we can see

32
00:02:25,450 --> 00:02:31,500
the same way put product by ID and delete product by ID with piercing the path parameters.

33
00:02:31,500 --> 00:02:32,550
Which information?

34
00:02:32,550 --> 00:02:34,080
Including the ID information.

35
00:02:34,410 --> 00:02:35,700
Okay, very good.

36
00:02:35,700 --> 00:02:42,780
So we have understand how Amazon API gateway triggered our lambda function and we get all incoming event

37
00:02:42,780 --> 00:02:50,120
JSON object in order to understand incoming event JSON structure and develop our lambda function code

38
00:02:50,130 --> 00:02:52,920
according to incoming structure of the JSON object.

39
00:02:53,070 --> 00:02:57,300
So now let's focus on the development into our index file.
