1
00:00:00,210 --> 00:00:05,730
In this video, we are going to create Lambda function for subscribing Amazon sans topic.

2
00:00:06,060 --> 00:00:10,950
So we will create the function that process events coming from the Amazon SAS topics.

3
00:00:10,950 --> 00:00:12,250
So let's get started.

4
00:00:12,270 --> 00:00:17,040
Please open the PlayStation console, go to Lambda functions and click the create function.

5
00:00:17,610 --> 00:00:21,210
This is the name of the function should be the goal goal function.

6
00:00:21,480 --> 00:00:26,430
If you scroll down, we are going to leave as it is for the other configurations and click the create

7
00:00:26,430 --> 00:00:27,300
function button.

8
00:00:29,120 --> 00:00:35,660
So as we learned from the Lambda asynchronous invocations, Amazon Sans invoke functions asynchronously

9
00:00:35,660 --> 00:00:37,100
to process the events.

10
00:00:37,220 --> 00:00:42,920
So when we invoke a function asynchronously, we don't wait a response from the function code and we

11
00:00:43,070 --> 00:00:45,910
hand off the event to lambda and lambda handle the rest.

12
00:00:45,920 --> 00:00:51,440
We can configure how lambda handle the errors and can send the invocation recourse to the DOM setting

13
00:00:51,450 --> 00:00:54,980
resources to chain together component or application.

14
00:00:54,980 --> 00:00:58,670
So we have successfully create goal function in the lambda.

15
00:00:58,670 --> 00:01:04,760
So if you scroll down and go to configurations and if you scroll down, if you open the asynchronous

16
00:01:04,760 --> 00:01:09,500
invocation, you can see the configurations about the asynchronous invocation.

17
00:01:09,500 --> 00:01:15,680
Basically Lambda manage the function asynchronous event queue and the attempts to retry on the errors.

18
00:01:15,710 --> 00:01:20,780
Here you can see two retry attempts setting up to or asynchronous invocation.

19
00:01:20,870 --> 00:01:26,810
If the function return an error lambda attempts to run it to two times with a one minute wait between

20
00:01:26,810 --> 00:01:31,360
the first two attempts and 2 minutes between the second and the third attempts.

21
00:01:31,370 --> 00:01:36,230
Function errors include the errors returned by the function code and the error return to by function

22
00:01:36,230 --> 00:01:38,060
runtime such as the timeout.

23
00:01:38,300 --> 00:01:41,660
So if you come to the permissions.

24
00:01:42,760 --> 00:01:43,900
And scroll down.

25
00:01:43,900 --> 00:01:49,630
We can see that we have created a new role, which is the execution role for this particular lambda

26
00:01:49,630 --> 00:01:50,260
function.

27
00:01:50,260 --> 00:01:53,560
And we have only Amazon colored watch permissions.

28
00:01:53,560 --> 00:02:00,190
But when sans invoke our function asynchronously, it needs to invoke Lambda permission into resource

29
00:02:00,190 --> 00:02:01,300
based policy section.

30
00:02:01,300 --> 00:02:06,910
If you scroll down, you can see the resource based policy and we don't have any resource based policy.

31
00:02:06,910 --> 00:02:13,780
But when it comes to invoke from the Psns this should be including an SNS record can be required permissions

32
00:02:13,780 --> 00:02:15,190
setting up in here.

33
00:02:15,190 --> 00:02:20,620
So when we subscribe our lambda function to the SNS, we should give required permission to SNS.

34
00:02:20,620 --> 00:02:25,210
In our case, permission is invoke lambda function from the SNS topics.
