1
00:00:00,150 --> 00:00:06,450
In this video, we are going to start developing our lambda function for incoming event from the SNS

2
00:00:06,450 --> 00:00:07,080
topic.

3
00:00:07,350 --> 00:00:13,200
When we developing our lambda function, we should know that incoming event JSON object from the Amazon

4
00:00:13,230 --> 00:00:14,160
SNS topic.

5
00:00:14,490 --> 00:00:21,060
There are several ways to know and we should check the test template on SNS notification from the lambda.

6
00:00:21,090 --> 00:00:27,540
So if you open the lambda function and go to test and if you scroll down you can see that we have different,

7
00:00:27,990 --> 00:00:31,130
different templates that we can see in this dropdown.

8
00:00:31,140 --> 00:00:37,560
And if you search for the SNS, you can see the SNS topic notification to lambda function is come in

9
00:00:37,560 --> 00:00:37,800
here.

10
00:00:37,800 --> 00:00:43,740
If you select this template, we can see the potential incoming event JSON from the SNS.

11
00:00:43,740 --> 00:00:49,980
I'm going to copy this even JSON object and paste into our visual pseudocode.

12
00:00:50,070 --> 00:00:54,060
As you remember that we have created a separate lecture and section folders.

13
00:00:54,060 --> 00:01:00,300
So in this section we got the incoming event JSON object from the SNS topic to a lambda.

14
00:01:00,330 --> 00:01:09,300
We can see that we have a records array and every array item including the SNS topic and even source

15
00:01:09,300 --> 00:01:13,080
is a SNS and you can see the event subscription.

16
00:01:13,080 --> 00:01:20,010
Aaron The SNS related information is under the SNS and you can get the type message ID topic and subject

17
00:01:20,010 --> 00:01:21,240
message and so on.

18
00:01:21,360 --> 00:01:26,850
So this is the incoming event JSON file from the SNS topic to Lambda function.

19
00:01:26,850 --> 00:01:33,180
And after that we can develop our lambda function if you come here and create a new index JS file,

20
00:01:33,360 --> 00:01:34,710
let me create index.

21
00:01:35,720 --> 00:01:42,710
JS Well, basically we will create a lambda function in here to make it basic lambda implementation.

22
00:01:42,830 --> 00:01:47,480
I'm going to log the incoming message from the SMS topic.

23
00:01:47,480 --> 00:01:51,890
So basically you can come here and see the event JSON.

24
00:01:51,890 --> 00:01:58,340
So if you come to spot and see the message, I'm going to get the message and log the message in the

25
00:01:58,340 --> 00:01:59,420
lambda function.

26
00:01:59,420 --> 00:02:03,490
So if you come back to our lambda function and develop lambda function in here.

27
00:02:03,500 --> 00:02:07,910
So basically this is the one handed method and the first line of code, we are logging the incoming

28
00:02:07,910 --> 00:02:11,600
event from the SMS topic and here you can see the our business logic.

29
00:02:11,600 --> 00:02:18,860
We basically get the event that records zero start message and get the message from the incoming event

30
00:02:18,860 --> 00:02:23,420
from the SMS topic and log this message into our cloud logs.

31
00:02:23,450 --> 00:02:28,850
Okay, this is the our lambda function and we are going to deploy this function to do so.

32
00:02:28,850 --> 00:02:38,510
Please open the a lambda and go to code part and copy codes from our application and paste into the.

33
00:02:40,200 --> 00:02:41,380
A Lambda function.

34
00:02:41,950 --> 00:02:48,160
Since this will trigger asynchronously, we don't return any response for our lambda function.

35
00:02:48,280 --> 00:02:53,530
I'm going to deploy this function and we have successfully deployed our function.

36
00:02:53,950 --> 00:02:55,690
So this is the asynchronous invocation.

37
00:02:55,690 --> 00:02:57,340
We don't return anything.

38
00:02:57,370 --> 00:03:03,850
To be simple, I only log the incoming message, but we will see some complex handle up in the next

39
00:03:03,850 --> 00:03:04,480
section.

40
00:03:04,480 --> 00:03:07,600
But now let's see how we can test and see.

41
00:03:07,600 --> 00:03:09,580
Incoming message from the lambda.
