In this video, we are going to start our hands on up.
Amazon asks Q Pulling from the lambda, you can see the architecture on the slide.
Basically we will send message to Amazon asks and this will be stored in the it will use Esquire's Q
and this Q item will be pulled from the Lambda event source mapping in location type and execute the
lambda function itself.
So lambda function will be triggered from the Amazon case.
Q And this communication type is pull based.
That means even source mapping.
So we will follow this these steps when we are performing these hands on loop.
First of all, we will create an Amazon SKU.
We will create a lambda function, create lambda trigger to Amazon asks Q to perform event source mapping.
They will have lambda function code for incoming event from the Amazon SKU and send message from the
Amazon case.
Q For testing to enter the architecture, as you know that when we implement any architecture on a case,
we have two main steps.
The first one is to create infrastructure on a cloud, and the second one is the developer Lambda Actual
code for interacting Amazon case.
So we will start with the first step which is the create infrastructure architecture on a cloud.
So let's get start to implement and create these services on a cloud environment.
Please open the management console and go to Amazon.
Q.
So make sure that you have no any other cues.
Please delete old cues after performing any hands on labs.
So come to cue records and create the cue.
I'm going to use standard cue and give the name of the cue.
I'm going to give the name as a.
My.
And after that, if you scroll down, we can set the configurations and other configuration properties.
I'm going to leave this and go at the end of this page and create queue by default settings.
Okay.
Now we have created my cue and it's the same way I'm going to create a lambda function.
Please open a lambda function in a different page.
So we are going to create a new function.
These will be from scratch.
And I'm giving the function name as my function and leave as it is for all configurations and click
the create function button.
This will be create a new execution role and any lambda function for us that we'll pull from the our
Amazon SKU.
But this is very similar step.
So OC after created our lambda function we should edit trigger.
So in order to perform event source mapping invocation, we are going to add the trigger to lambda function
which triggers from the ESCS.
So click this button and search for the case.
Let's wait for a while.
Click the Amazon case, choose the ESC screw, which is the micro and enable trigger and you can set
the batch size and the batch window.
These are the important properties when you are working with the millions of records request.
So I'm leaving a default values, which is the best size and batch window, and I don't set any additional
settings and click the ad button.
So when I click the head button, you can see that we got an exception, which is the exception about
when creating a trigger.
The provided execution role doesn't have permission to call receive message on case.
So that means when Lambda pulls request from the Amazon case, this is required to permission receive
message of the Amazon SDKs.
So for that purpose we should add required permission to the Lambda execution role.
To do that, please go to Lambda Function and go to Lambda open our lambda function and go to a permissions
configuration permission and go to execution role and these will be open IAM rules.
So in the IAM role, we basically attach policy for the receive message.
You can see that we are in IOM page, which is the identity and access management and this is our newly
created role for our lambda function.
And if you scroll down you can see the permissions and we can basically add permission and attach policies.
So which policy we should attach.
So basically we need to attach a skills crew execution.
I'm going to copy and paste and you can search for the case crew.
And if you search for the sky, you can see that this is the Lambda SKU execution rule.
If you expand this policy, you can see that the actions it is allowing the receive message.
So we would like to receive message and also delete message from the lambda.
So that's why we should add this execution role into our lambda execution role.
So select this one and attach policies.
By the way, this is the best practice to find minimum permission to your use cases.
So please check the for example, if you would like to communicate with the SNS, check for the service
and find the least minimum permission from the policies and attach that policy into your execution roll.
This is the best practice.
So after we have adding to policy, we should check from the lambda function.
Come here and refresh this page.
And go to configuration and permission verify from the resource summary.
If you open this dropdown you can see the Amazon space and click the Amazon space and see that.
Now we can allow the receive message and delete message.
So that means now Lambda can pull message from the Amazon space, so we should edit it.
Now come to my function and click the trigger and select the case and give the our queue name.
Scroll down and click the aid button.
This time we have successfully added trigger or asks and if we check from the Amazon space, please
open the Amazon.
In this case, go to use open the micro.
If you scroll down and select the lambda triggers, you can see the lambda trigger is come here.
That means this excuse message can pull from the lambda function.
Okay.
As you can see that we have configured our Lambda and Amazon SKU.
Now if we send a message to Amazon case, this will pull from the lambda function with the event source
mapping location and execute with the incoming message.