1
00:00:00,120 --> 00:00:06,270
In this video, we are going to create infrastructure for public subscription and architecture with

2
00:00:06,270 --> 00:00:12,850
SAS, X and Lambda, so that means we will create infrastructure for our hands on lab.

3
00:00:12,870 --> 00:00:17,330
Here you can see the overall architecture that we are going to build in this hands on section.

4
00:00:17,340 --> 00:00:19,710
So we will start with creating infrastructure.

5
00:00:19,710 --> 00:00:26,340
So that means we will create API, gateway, lambda function, dynamic DB Table, SNS, three, SQL

6
00:00:26,350 --> 00:00:30,690
SKU and three downstream microservices on our cloud environment.

7
00:00:31,020 --> 00:00:36,990
So I'm going to start with creating order acknowledgement microservice lambda function for that purpose.

8
00:00:36,990 --> 00:00:44,330
Please open the A management console and go to Lambda Page and go to the Lambda functions and create

9
00:00:44,340 --> 00:00:45,390
new function.

10
00:00:45,840 --> 00:00:51,270
So we will create order from the sketch and the function name will be the order acknowledgements.

11
00:00:51,810 --> 00:00:57,120
If you scroll down, we are going to leave as it is this runtime and architecture and we should set

12
00:00:57,120 --> 00:00:58,230
the permissions.

13
00:00:58,230 --> 00:01:01,430
I'm going to expand this permission tab.

14
00:01:01,740 --> 00:01:07,110
So basically the default one is creating a new role with the basic lambda permission.

15
00:01:07,110 --> 00:01:10,920
But in our case, we need additional policy and permissions.

16
00:01:10,920 --> 00:01:18,120
So for that purpose, please select the create any rule from a which policy templates and I would like

17
00:01:18,120 --> 00:01:19,560
to give the role name.

18
00:01:19,560 --> 00:01:27,600
We can give the role name or the role and if you scroll down, we can specify the policy template.

19
00:01:27,630 --> 00:01:33,510
It is very important I will set the policy template and explain after that so you can come here and

20
00:01:33,510 --> 00:01:38,460
search for the Dynamo DB and select simple Microsoft permissions.

21
00:01:38,460 --> 00:01:44,250
And after that you can come here and search for the Psns and select the Psns publish policy.

22
00:01:44,640 --> 00:01:45,360
Okay.

23
00:01:45,360 --> 00:01:51,210
So that means we have give the policy template the NEAVE Rule, which is the Order Act role with the

24
00:01:51,210 --> 00:01:52,740
simple microservice permission.

25
00:01:52,740 --> 00:01:57,570
This is the Dynamo DB permissions and also SAS public policy permission.

26
00:01:57,660 --> 00:02:02,730
This is one important feature that we set the required permissions when creating lambda function with

27
00:02:02,730 --> 00:02:04,050
the understandable names.

28
00:02:04,350 --> 00:02:10,980
If you come back to our architecture according to our architecture, we publish a SMS message from our

29
00:02:10,980 --> 00:02:12,990
order acknowledged microservices.

30
00:02:12,990 --> 00:02:16,320
So it needs to authorization of SNS publish action.

31
00:02:16,320 --> 00:02:20,070
Otherwise it will getting error about the authorization error.

32
00:02:20,070 --> 00:02:23,190
We cannot publish the system of the Psns.

33
00:02:23,340 --> 00:02:29,100
So basically we should think the lambda interactions and give the required permissions of the execution

34
00:02:29,100 --> 00:02:29,580
role.

35
00:02:29,580 --> 00:02:32,460
So we have required to permission.

36
00:02:32,460 --> 00:02:40,260
If you design your permissions, basically we have order acknowledge microservices and it is two actions.

37
00:02:40,260 --> 00:02:45,690
The first action is publishing the Psns and the second actions inserting any item in Dynamo.

38
00:02:45,690 --> 00:02:51,720
DB So that means put Dynamo DB If you look at the inventory database, you can come here and see that

39
00:02:51,720 --> 00:02:57,960
we have if we have a Dynamo DB table, we can also require to put Dynamo DB table.

40
00:02:58,170 --> 00:02:58,540
Okay.

41
00:02:58,710 --> 00:03:05,880
Now we have understood how we can create these order exclusion microservices and give required permissions.

42
00:03:05,880 --> 00:03:11,910
If you come back to our A Willis management console and if you scroll down click to create function,

43
00:03:11,910 --> 00:03:17,550
we will create order acknowledgment function with these policies and after that we will check these

44
00:03:17,550 --> 00:03:21,120
policies is affected, correct or not?

45
00:03:22,540 --> 00:03:25,240
Look, our function is created successfully.

46
00:03:25,270 --> 00:03:30,910
If you scroll down, go to configuration and go to permissions, you can see that we have now Dynamo

47
00:03:30,910 --> 00:03:32,920
DB and Amazon sans permission.

48
00:03:32,920 --> 00:03:38,770
If you open the Dynamo DB, you can see the all CRUD operations performed from the are execution role,

49
00:03:38,800 --> 00:03:40,420
which is the order role.

50
00:03:41,080 --> 00:03:47,020
And also if you select the Amazon Psns, you can see that we are allowing SAS publish operation.

51
00:03:47,020 --> 00:03:52,420
So that means we give required permissions successfully and we have create order, acknowledge microservice

52
00:03:52,420 --> 00:03:53,770
lambda function successfully.

53
00:03:53,770 --> 00:03:56,530
Now we can continue the other services.

54
00:03:56,560 --> 00:04:01,780
Now I'm going to create API, Gateway Rest API to perform our infrastructure.

55
00:04:01,780 --> 00:04:06,940
So to do that, please open the console and go to API Gateway.

56
00:04:07,480 --> 00:04:12,340
We will create an API gateway to expose API to client application.

57
00:04:12,340 --> 00:04:16,570
So if you scroll down, we will create a rest API and click the boot button.

58
00:04:18,450 --> 00:04:25,830
So we will create rest API and this will be new API and give the API name as a order API because we

59
00:04:25,830 --> 00:04:32,460
will place an order with the client application and leave as it is for other configurations and click

60
00:04:32,460 --> 00:04:33,780
the create API button.

61
00:04:35,210 --> 00:04:40,190
So after that we will create action, create resource for our application.

62
00:04:40,190 --> 00:04:46,730
So basically I'm going to create a resource which name is order and create click to create resource

63
00:04:46,730 --> 00:04:47,090
button.

64
00:04:48,990 --> 00:04:51,930
And after that we can add a method into our resource.

65
00:04:51,960 --> 00:04:58,590
So I would like to add on the post method because this will be the post operation, ACP Post operation,

66
00:04:58,590 --> 00:05:03,940
place an order or check out an order, collect the post operation and set the integration type.

67
00:05:03,960 --> 00:05:04,920
Lambda function.

68
00:05:04,920 --> 00:05:09,320
And please don't forget to check this box, which is the use lambda proxy integration.

69
00:05:09,330 --> 00:05:16,260
And after that we will give the lambda function which name is order acknowledgment and click the save

70
00:05:16,260 --> 00:05:16,800
button.

71
00:05:17,920 --> 00:05:21,700
And give the required permission with giving to och och.

72
00:05:21,700 --> 00:05:28,510
So we basically create our API and this will be triggered to our order acknowledgement microservices

73
00:05:28,630 --> 00:05:33,130
in order to test these post http, we should go to stage.

74
00:05:33,130 --> 00:05:35,740
But before that of course we should deploy this API.

75
00:05:35,740 --> 00:05:39,580
So let's go to deploy API and see what's happened.

76
00:05:40,740 --> 00:05:42,410
We should create a new stage.

77
00:05:42,420 --> 00:05:47,190
I'm going to create a stage name which a production and connected button.

78
00:05:48,290 --> 00:05:55,390
Yes, we have successfully deployed our order API gateway and if you go to the Post method in the States

79
00:05:55,430 --> 00:05:59,140
section, you can copy this emotional.

80
00:05:59,210 --> 00:06:07,400
And if you go to the postman and paste in here and click the method as a post and click the send button.

81
00:06:07,580 --> 00:06:12,860
So as you can see that this is typical to our lambda function and we have create a HTTP post method

82
00:06:12,860 --> 00:06:13,880
successfully.

83
00:06:14,240 --> 00:06:18,790
Now we have created API gateway and order lambda function.

84
00:06:18,800 --> 00:06:22,220
Now it is time to create order table on Dynamo DB.

85
00:06:22,250 --> 00:06:28,580
For that purpose please open the mission console and we will also create an immature database in here

86
00:06:28,580 --> 00:06:33,200
in case of the eventual database store items in the Dynamo DB table.

87
00:06:33,290 --> 00:06:37,220
So please open the management console and click the create table.

88
00:06:37,220 --> 00:06:42,920
Go to Dynamo DB and click the create table and give the name of the table name as a order and partition

89
00:06:42,920 --> 00:06:47,570
key will be ID and we don't have any sort key for the order table.

90
00:06:47,570 --> 00:06:54,460
And if you scroll down we can set the customized settings and if you scroll down we can select the capacity

91
00:06:54,470 --> 00:06:55,900
mode as the on demand.

92
00:06:55,910 --> 00:07:00,680
So if you scroll down, leave as it is for other complications and click the create table button.

93
00:07:01,860 --> 00:07:04,590
Look, our on the table is creating.

94
00:07:04,620 --> 00:07:07,890
If you refresh this page, you will check the status.

95
00:07:07,890 --> 00:07:12,930
And I'm going to create another dynamic DB table, which is the inventory table.

96
00:07:12,930 --> 00:07:16,560
And this time the partition key will be the code.

97
00:07:16,560 --> 00:07:19,760
And if you scroll down, I don't change any sort, okay?

98
00:07:19,770 --> 00:07:25,440
And customize the settings and only change the compass mode as the on demand and follow the same steps

99
00:07:25,440 --> 00:07:26,850
and click the create table.

100
00:07:27,270 --> 00:07:33,270
So as you can see that we have created two dynamic table one for the order, one for the inventory.

101
00:07:33,270 --> 00:07:36,210
You can refresh and see the status is active.

102
00:07:36,210 --> 00:07:43,440
Now if you look at our architecture, we can go to the downstream microservices and we will create three

103
00:07:43,440 --> 00:07:48,780
lambda function as a DOM state in microservices and these will be interact with the Amazon case.

104
00:07:48,780 --> 00:07:55,560
So that means pull items from the Amazon SQL six to process the items, internal lambda functions.

105
00:07:55,560 --> 00:08:02,250
So basically we will add the required permissions for the polling space into these three downstream

106
00:08:02,250 --> 00:08:08,800
lambda microservices and also in your database also interact with the dynamic DB to store and deduct

107
00:08:08,800 --> 00:08:12,390
the table items into the Dynamo DB table.

108
00:08:12,450 --> 00:08:15,180
Okay, let's get started for that purpose.

109
00:08:15,180 --> 00:08:20,640
Open the A management console and go to the Lambda functions and create function.

110
00:08:20,640 --> 00:08:26,460
So I'm going to start with our notification microservices.

111
00:08:26,460 --> 00:08:34,920
You can come here and say that notification microservices and expand the permissions and select the

112
00:08:34,920 --> 00:08:37,650
create a new role from the policy template.

113
00:08:37,650 --> 00:08:42,240
And the role name is a notification role and the policy templates.

114
00:08:42,240 --> 00:08:47,160
We should search for the case and you can see the Amazon case folder permission.

115
00:08:47,160 --> 00:08:53,580
So if you look at the architecture, you can see that all our downstream microservices pulling item

116
00:08:53,580 --> 00:08:58,530
from the case and this is required permission from the lambda execution role.

117
00:08:58,530 --> 00:09:05,400
You can think that if any arrow start from the lambda function and goes to another ADA services.

118
00:09:05,400 --> 00:09:10,770
So that means we should require permission into execution role of the lambda function.

119
00:09:10,800 --> 00:09:17,640
When we are creating this function, it is good to find the role name and policy name in here and set

120
00:09:17,640 --> 00:09:20,400
in in the stage of the creating lambda function.

121
00:09:20,610 --> 00:09:26,100
Okay, make sure that you have select the case folder permission and now we can create our notification

122
00:09:26,100 --> 00:09:28,920
microservices and click the create function button.

123
00:09:29,460 --> 00:09:32,400
Notification Microservice is created successfully.

124
00:09:32,430 --> 00:09:39,420
Now it is time to go to our other downstream services, which is the immature database, immature lambda

125
00:09:39,420 --> 00:09:40,020
function.

126
00:09:40,020 --> 00:09:46,500
So if you look at the, the permission of the inventory, you can think that immature database has two

127
00:09:46,500 --> 00:09:47,190
arrows.

128
00:09:47,190 --> 00:09:52,530
And the first one is the case poller and the other one dynamically we put because we have created immature

129
00:09:52,530 --> 00:09:53,900
database on Dynamo.

130
00:09:53,920 --> 00:10:00,270
DB This will be also required to interact with the Dynamo DB So that means when we are creating lambda

131
00:10:00,270 --> 00:10:05,490
functions is the same way we are designing the permissions as you can see that immature required to

132
00:10:05,490 --> 00:10:12,270
permissions we also it is pulling from the space and the other all downstream microservices is required

133
00:10:12,270 --> 00:10:15,210
only one permission which is the space polar.

134
00:10:15,210 --> 00:10:20,820
So let's get start to implement immature the immature lambda function if you go back to lambda functions

135
00:10:20,820 --> 00:10:22,320
and create a new function.

136
00:10:24,010 --> 00:10:28,150
And these will be the inventory microservices.

137
00:10:28,600 --> 00:10:34,150
And if you scroll down, expand these permissions, create a new role and you can give the eventual

138
00:10:34,150 --> 00:10:37,630
role and say the policy template is a case folder.

139
00:10:37,630 --> 00:10:40,270
And also I would like to interact with the Dynamo.

140
00:10:40,270 --> 00:10:44,530
DB You can search and select for the simple microservice permission.

141
00:10:44,740 --> 00:10:49,780
OC Make sure that you have give to policy permission and click the create function button.

142
00:10:50,110 --> 00:10:52,480
Eventually microservice created successfully.

143
00:10:52,510 --> 00:10:57,310
Now I'm following the same step for the shipment microservices.

144
00:10:57,670 --> 00:11:04,270
For that purpose I'm going to create microservices, expand the permission, create a new role which

145
00:11:04,270 --> 00:11:08,050
is a shipment role and give the policy templates.

146
00:11:08,050 --> 00:11:16,360
This will be the case polar OC and click the create function button OC shipment microservice also created

147
00:11:16,360 --> 00:11:17,230
successfully.

148
00:11:17,260 --> 00:11:22,900
If you go back to lambda function, you should have for lambda function, which all are the microservices

149
00:11:22,900 --> 00:11:24,160
in our architecture.

150
00:11:24,190 --> 00:11:30,820
If you go back to our architecture, we have create all lambda microservices API, gateway dynamic DB

151
00:11:30,820 --> 00:11:31,420
tables.

152
00:11:31,450 --> 00:11:34,000
Now we have list sense and space.

153
00:11:34,000 --> 00:11:39,190
I'm going to create three queue for all these downstream microservices.

154
00:11:39,190 --> 00:11:48,010
For that purpose please open the A console and go to Amazon SDKs and we will create three queue and

155
00:11:48,010 --> 00:11:49,660
I'm going to click the create queue.

156
00:11:49,660 --> 00:11:53,860
This will be the standard queue and I will start with the notification queue.

157
00:11:53,860 --> 00:11:59,470
So that means I'm going to create this queue which is notification queue and continue with the immature

158
00:11:59,470 --> 00:12:00,730
queue and the shipment queue.

159
00:12:00,760 --> 00:12:03,130
Go back to our console.

160
00:12:03,160 --> 00:12:08,620
This is the to create queue operation set the name the queue and I'm going to leave as it is for all

161
00:12:08,620 --> 00:12:09,730
configurations.

162
00:12:09,730 --> 00:12:12,460
And if you scroll down, click to create queue.

163
00:12:12,760 --> 00:12:19,300
So as you can see we have create our first queue and follow the same steps for the other queues, which

164
00:12:19,300 --> 00:12:24,400
is the inventory queue and the shipment queue I'm creating eventually queue now.

165
00:12:25,720 --> 00:12:27,580
And also I'm going to create.

166
00:12:28,690 --> 00:12:36,050
It's created and I'm going to create last Q All these Q should be standard and this name of the Q is

167
00:12:36,050 --> 00:12:36,520
the achievement.

168
00:12:36,550 --> 00:12:42,730
Q If you scroll down and create Q we have created three Qs for our architecture.

169
00:12:42,730 --> 00:12:47,200
So now it is time to create event source mapping invocation.

170
00:12:47,200 --> 00:12:53,050
So for that purpose, basically if you open the architecture, you can see that we have create these

171
00:12:53,050 --> 00:12:54,510
lambda function and these skills.

172
00:12:54,640 --> 00:13:01,450
Q Now it is time to interact with the lambda functions from the space with adding the trigger to lambda

173
00:13:01,450 --> 00:13:08,080
function for providing event source mapping, pulling in location, in location set up for that purpose,

174
00:13:08,080 --> 00:13:13,090
please open the lambda functions one by one and a trigger for the Amazon case.

175
00:13:13,090 --> 00:13:19,810
So I'm going to go to Lambda Functions and for example, open the notification microservice and I'm

176
00:13:19,810 --> 00:13:21,550
going to add a trigger.

177
00:13:21,550 --> 00:13:26,350
And this time trigger will be the case, which will be the notification.

178
00:13:26,410 --> 00:13:29,680
Q And if you select the case and select notification.

179
00:13:29,680 --> 00:13:37,090
Q We are going to add an event source mapping communication with the case in this Lambda Microservices.

180
00:13:37,090 --> 00:13:42,910
So if you expand the addition setting, we don't set any configuration and click the aid button.

181
00:13:43,210 --> 00:13:50,530
So when you click the red button is you can see that we have added successfully this aqueous message

182
00:13:50,530 --> 00:13:52,450
to our notification microservices.

183
00:13:52,450 --> 00:13:55,900
So if you scroll down you can see the triggers as a notification.

184
00:13:55,900 --> 00:14:01,540
Q And this will be triggered notification microservices and you can see all the tests in here.

185
00:14:01,570 --> 00:14:07,300
Also, as you remember that when we create our notification microservices in the permissions, we have

186
00:14:07,300 --> 00:14:09,880
added the Amazon case poller.

187
00:14:09,880 --> 00:14:17,650
And if you look at the again Amazon SDKs, you can see that Amazon case receive message is allowing

188
00:14:17,650 --> 00:14:18,760
for this action.

189
00:14:18,760 --> 00:14:24,070
So this is very important when you are adding event source mapping, pulling in location from case to

190
00:14:24,070 --> 00:14:29,560
lambda microservices, these permissions should be required and mandatory and make sure that you have

191
00:14:30,130 --> 00:14:33,360
received message per into your permission top.

192
00:14:33,460 --> 00:14:34,570
Okay, very good.

193
00:14:34,570 --> 00:14:39,790
We have communicated with the SKU of the notification and notification microservices.

194
00:14:39,790 --> 00:14:47,380
So that means we will complete these line of services and now I am going to set the manager to eventual

195
00:14:47,380 --> 00:14:47,820
excuse.

196
00:14:47,830 --> 00:14:53,950
Q If you come back to the management console now, go to functions and go to inventory microservices

197
00:14:54,070 --> 00:15:02,530
and a trigger, select the source is a case and give the case queue as a inventory queue and leave as

198
00:15:02,530 --> 00:15:04,990
it is all complications and click the button.

199
00:15:06,600 --> 00:15:13,590
Look, we have successfully aided even source mapping with the eventually HQ, HQ and the eventual microservices.

200
00:15:13,590 --> 00:15:18,930
You can see the configurations and make sure that you have added eventually for the eventual microservices

201
00:15:18,930 --> 00:15:20,430
and you can check the permissions.

202
00:15:20,430 --> 00:15:25,350
We have asks for permission which including SDKs, receive message.

203
00:15:25,350 --> 00:15:31,470
So follow the same thing for the last three microservices, which is the same with microservices to

204
00:15:31,470 --> 00:15:37,350
open the ship with Microsoft lambda function, click the trigger, select a resource as a case and select

205
00:15:37,350 --> 00:15:40,710
the queue as a shipment queue and click the red button.

206
00:15:42,300 --> 00:15:42,930
Okay.

207
00:15:43,050 --> 00:15:46,300
As you can see that we have successfully at square school.

208
00:15:46,320 --> 00:15:50,550
So that means we have complete all these parts into our architecture.

209
00:15:50,580 --> 00:15:55,320
The only thing we have left is creating a modern sense that we will create in the next video.
