In this video, we are going to create infrastructure for public subscription and architecture with
SAS, X and Lambda, so that means we will create infrastructure for our hands on lab.
Here you can see the overall architecture that we are going to build in this hands on section.
So we will start with creating infrastructure.
So that means we will create API, gateway, lambda function, dynamic DB Table, SNS, three, SQL
SKU and three downstream microservices on our cloud environment.
So I'm going to start with creating order acknowledgement microservice lambda function for that purpose.
Please open the A management console and go to Lambda Page and go to the Lambda functions and create
new function.
So we will create order from the sketch and the function name will be the order acknowledgements.
If you scroll down, we are going to leave as it is this runtime and architecture and we should set
the permissions.
I'm going to expand this permission tab.
So basically the default one is creating a new role with the basic lambda permission.
But in our case, we need additional policy and permissions.
So for that purpose, please select the create any rule from a which policy templates and I would like
to give the role name.
We can give the role name or the role and if you scroll down, we can specify the policy template.
It is very important I will set the policy template and explain after that so you can come here and
search for the Dynamo DB and select simple Microsoft permissions.
And after that you can come here and search for the Psns and select the Psns publish policy.
Okay.
So that means we have give the policy template the NEAVE Rule, which is the Order Act role with the
simple microservice permission.
This is the Dynamo DB permissions and also SAS public policy permission.
This is one important feature that we set the required permissions when creating lambda function with
the understandable names.
If you come back to our architecture according to our architecture, we publish a SMS message from our
order acknowledged microservices.
So it needs to authorization of SNS publish action.
Otherwise it will getting error about the authorization error.
We cannot publish the system of the Psns.
So basically we should think the lambda interactions and give the required permissions of the execution
role.
So we have required to permission.
If you design your permissions, basically we have order acknowledge microservices and it is two actions.
The first action is publishing the Psns and the second actions inserting any item in Dynamo.
DB So that means put Dynamo DB If you look at the inventory database, you can come here and see that
we have if we have a Dynamo DB table, we can also require to put Dynamo DB table.
Okay.
Now we have understood how we can create these order exclusion microservices and give required permissions.
If you come back to our A Willis management console and if you scroll down click to create function,
we will create order acknowledgment function with these policies and after that we will check these
policies is affected, correct or not?
Look, our function is created successfully.
If you scroll down, go to configuration and go to permissions, you can see that we have now Dynamo
DB and Amazon sans permission.
If you open the Dynamo DB, you can see the all CRUD operations performed from the are execution role,
which is the order role.
And also if you select the Amazon Psns, you can see that we are allowing SAS publish operation.
So that means we give required permissions successfully and we have create order, acknowledge microservice
lambda function successfully.
Now we can continue the other services.
Now I'm going to create API, Gateway Rest API to perform our infrastructure.
So to do that, please open the console and go to API Gateway.
We will create an API gateway to expose API to client application.
So if you scroll down, we will create a rest API and click the boot button.
So we will create rest API and this will be new API and give the API name as a order API because we
will place an order with the client application and leave as it is for other configurations and click
the create API button.
So after that we will create action, create resource for our application.
So basically I'm going to create a resource which name is order and create click to create resource
button.
And after that we can add a method into our resource.
So I would like to add on the post method because this will be the post operation, ACP Post operation,
place an order or check out an order, collect the post operation and set the integration type.
Lambda function.
And please don't forget to check this box, which is the use lambda proxy integration.
And after that we will give the lambda function which name is order acknowledgment and click the save
button.
And give the required permission with giving to och och.
So we basically create our API and this will be triggered to our order acknowledgement microservices
in order to test these post http, we should go to stage.
But before that of course we should deploy this API.
So let's go to deploy API and see what's happened.
We should create a new stage.
I'm going to create a stage name which a production and connected button.
Yes, we have successfully deployed our order API gateway and if you go to the Post method in the States
section, you can copy this emotional.
And if you go to the postman and paste in here and click the method as a post and click the send button.
So as you can see that this is typical to our lambda function and we have create a HTTP post method
successfully.
Now we have created API gateway and order lambda function.
Now it is time to create order table on Dynamo DB.
For that purpose please open the mission console and we will also create an immature database in here
in case of the eventual database store items in the Dynamo DB table.
So please open the management console and click the create table.
Go to Dynamo DB and click the create table and give the name of the table name as a order and partition
key will be ID and we don't have any sort key for the order table.
And if you scroll down we can set the customized settings and if you scroll down we can select the capacity
mode as the on demand.
So if you scroll down, leave as it is for other complications and click the create table button.
Look, our on the table is creating.
If you refresh this page, you will check the status.
And I'm going to create another dynamic DB table, which is the inventory table.
And this time the partition key will be the code.
And if you scroll down, I don't change any sort, okay?
And customize the settings and only change the compass mode as the on demand and follow the same steps
and click the create table.
So as you can see that we have created two dynamic table one for the order, one for the inventory.
You can refresh and see the status is active.
Now if you look at our architecture, we can go to the downstream microservices and we will create three
lambda function as a DOM state in microservices and these will be interact with the Amazon case.
So that means pull items from the Amazon SQL six to process the items, internal lambda functions.
So basically we will add the required permissions for the polling space into these three downstream
lambda microservices and also in your database also interact with the dynamic DB to store and deduct
the table items into the Dynamo DB table.
Okay, let's get started for that purpose.
Open the A management console and go to the Lambda functions and create function.
So I'm going to start with our notification microservices.
You can come here and say that notification microservices and expand the permissions and select the
create a new role from the policy template.
And the role name is a notification role and the policy templates.
We should search for the case and you can see the Amazon case folder permission.
So if you look at the architecture, you can see that all our downstream microservices pulling item
from the case and this is required permission from the lambda execution role.
You can think that if any arrow start from the lambda function and goes to another ADA services.
So that means we should require permission into execution role of the lambda function.
When we are creating this function, it is good to find the role name and policy name in here and set
in in the stage of the creating lambda function.
Okay, make sure that you have select the case folder permission and now we can create our notification
microservices and click the create function button.
Notification Microservice is created successfully.
Now it is time to go to our other downstream services, which is the immature database, immature lambda
function.
So if you look at the, the permission of the inventory, you can think that immature database has two
arrows.
And the first one is the case poller and the other one dynamically we put because we have created immature
database on Dynamo.
DB This will be also required to interact with the Dynamo DB So that means when we are creating lambda
functions is the same way we are designing the permissions as you can see that immature required to
permissions we also it is pulling from the space and the other all downstream microservices is required
only one permission which is the space polar.
So let's get start to implement immature the immature lambda function if you go back to lambda functions
and create a new function.
And these will be the inventory microservices.
And if you scroll down, expand these permissions, create a new role and you can give the eventual
role and say the policy template is a case folder.
And also I would like to interact with the Dynamo.
DB You can search and select for the simple microservice permission.
OC Make sure that you have give to policy permission and click the create function button.
Eventually microservice created successfully.
Now I'm following the same step for the shipment microservices.
For that purpose I'm going to create microservices, expand the permission, create a new role which
is a shipment role and give the policy templates.
This will be the case polar OC and click the create function button OC shipment microservice also created
successfully.
If you go back to lambda function, you should have for lambda function, which all are the microservices
in our architecture.
If you go back to our architecture, we have create all lambda microservices API, gateway dynamic DB
tables.
Now we have list sense and space.
I'm going to create three queue for all these downstream microservices.
For that purpose please open the A console and go to Amazon SDKs and we will create three queue and
I'm going to click the create queue.
This will be the standard queue and I will start with the notification queue.
So that means I'm going to create this queue which is notification queue and continue with the immature
queue and the shipment queue.
Go back to our console.
This is the to create queue operation set the name the queue and I'm going to leave as it is for all
configurations.
And if you scroll down, click to create queue.
So as you can see we have create our first queue and follow the same steps for the other queues, which
is the inventory queue and the shipment queue I'm creating eventually queue now.
And also I'm going to create.
It's created and I'm going to create last Q All these Q should be standard and this name of the Q is
the achievement.
Q If you scroll down and create Q we have created three Qs for our architecture.
So now it is time to create event source mapping invocation.
So for that purpose, basically if you open the architecture, you can see that we have create these
lambda function and these skills.
Q Now it is time to interact with the lambda functions from the space with adding the trigger to lambda
function for providing event source mapping, pulling in location, in location set up for that purpose,
please open the lambda functions one by one and a trigger for the Amazon case.
So I'm going to go to Lambda Functions and for example, open the notification microservice and I'm
going to add a trigger.
And this time trigger will be the case, which will be the notification.
Q And if you select the case and select notification.
Q We are going to add an event source mapping communication with the case in this Lambda Microservices.
So if you expand the addition setting, we don't set any configuration and click the aid button.
So when you click the red button is you can see that we have added successfully this aqueous message
to our notification microservices.
So if you scroll down you can see the triggers as a notification.
Q And this will be triggered notification microservices and you can see all the tests in here.
Also, as you remember that when we create our notification microservices in the permissions, we have
added the Amazon case poller.
And if you look at the again Amazon SDKs, you can see that Amazon case receive message is allowing
for this action.
So this is very important when you are adding event source mapping, pulling in location from case to
lambda microservices, these permissions should be required and mandatory and make sure that you have
received message per into your permission top.
Okay, very good.
We have communicated with the SKU of the notification and notification microservices.
So that means we will complete these line of services and now I am going to set the manager to eventual
excuse.
Q If you come back to the management console now, go to functions and go to inventory microservices
and a trigger, select the source is a case and give the case queue as a inventory queue and leave as
it is all complications and click the button.
Look, we have successfully aided even source mapping with the eventually HQ, HQ and the eventual microservices.
You can see the configurations and make sure that you have added eventually for the eventual microservices
and you can check the permissions.
We have asks for permission which including SDKs, receive message.
So follow the same thing for the last three microservices, which is the same with microservices to
open the ship with Microsoft lambda function, click the trigger, select a resource as a case and select
the queue as a shipment queue and click the red button.
Okay.
As you can see that we have successfully at square school.
So that means we have complete all these parts into our architecture.
The only thing we have left is creating a modern sense that we will create in the next video.