In this video, we are going to create Lambda function for subscribing Amazon sans topic.
So we will create the function that process events coming from the Amazon SAS topics.
So let's get started.
Please open the PlayStation console, go to Lambda functions and click the create function.
This is the name of the function should be the goal goal function.
If you scroll down, we are going to leave as it is for the other configurations and click the create
function button.
So as we learned from the Lambda asynchronous invocations, Amazon Sans invoke functions asynchronously
to process the events.
So when we invoke a function asynchronously, we don't wait a response from the function code and we
hand off the event to lambda and lambda handle the rest.
We can configure how lambda handle the errors and can send the invocation recourse to the DOM setting
resources to chain together component or application.
So we have successfully create goal function in the lambda.
So if you scroll down and go to configurations and if you scroll down, if you open the asynchronous
invocation, you can see the configurations about the asynchronous invocation.
Basically Lambda manage the function asynchronous event queue and the attempts to retry on the errors.
Here you can see two retry attempts setting up to or asynchronous invocation.
If the function return an error lambda attempts to run it to two times with a one minute wait between
the first two attempts and 2 minutes between the second and the third attempts.
Function errors include the errors returned by the function code and the error return to by function
runtime such as the timeout.
So if you come to the permissions.
And scroll down.
We can see that we have created a new role, which is the execution role for this particular lambda
function.
And we have only Amazon colored watch permissions.
But when sans invoke our function asynchronously, it needs to invoke Lambda permission into resource
based policy section.
If you scroll down, you can see the resource based policy and we don't have any resource based policy.
But when it comes to invoke from the Psns this should be including an SNS record can be required permissions
setting up in here.
So when we subscribe our lambda function to the SNS, we should give required permission to SNS.
In our case, permission is invoke lambda function from the SNS topics.