1
00:00:00,270 --> 00:00:06,000
In this video, we are going to create a rest API in API gateway for product microservices.

2
00:00:06,780 --> 00:00:12,540
So when our API method receives an HTTP request, API gateway invokes our lambda function.

3
00:00:13,110 --> 00:00:20,310
To do so, we should design our API methods that we will be exposed to the client application and redirect

4
00:00:20,310 --> 00:00:22,740
to the product microservice lambda function.

5
00:00:23,070 --> 00:00:27,780
In order to do that, please open the widgets to the code I have created in this section and the lecture

6
00:00:27,780 --> 00:00:30,390
and create API design text document.

7
00:00:30,660 --> 00:00:34,110
Basically this is the product API gateway API design.

8
00:00:34,140 --> 00:00:36,060
Here you can find our route name.

9
00:00:36,060 --> 00:00:41,850
Route name will be the product and under the route name we will get and post request.

10
00:00:41,880 --> 00:00:48,270
This will be the HTTP methods and after that we will add resource on the product, which is the ID to

11
00:00:48,270 --> 00:00:52,590
perform, get by ID, update by ID and delete by ID operations.

12
00:00:52,590 --> 00:00:58,080
So let's get start to create these infrastructure on a list environment.

13
00:00:58,080 --> 00:01:00,900
To do that, please open the A management console.

14
00:01:00,900 --> 00:01:03,690
In a managed console, go to API Gateway.

15
00:01:03,720 --> 00:01:06,210
You can see the different API types.

16
00:01:06,210 --> 00:01:13,050
We will use Rest API to perform these product micro service, hands on lab click the button.

17
00:01:14,670 --> 00:01:16,420
And we will follow the same steps.

18
00:01:16,440 --> 00:01:18,800
These will be the rest and API.

19
00:01:18,840 --> 00:01:24,300
API name will be the product API and it type will be the regional and click to create button.

20
00:01:25,440 --> 00:01:33,170
So in here we will start our resources, come to actions and create a resource which name is product?

21
00:01:33,180 --> 00:01:35,100
So create resource.

22
00:01:35,610 --> 00:01:40,060
And under this resource we have a get method.

23
00:01:40,080 --> 00:01:44,670
For that purpose, I'm going to create method, which is the get method.

24
00:01:45,060 --> 00:01:49,110
Click this icon and integration type should be lambda.

25
00:01:49,140 --> 00:01:52,410
Make sure that you have checked this lambda proxy integration.

26
00:01:52,410 --> 00:01:53,670
This is very important.

27
00:01:53,670 --> 00:01:57,630
And also we will give the lambda function as a product function.

28
00:01:57,660 --> 00:02:01,080
Click the save button and give required permission with.

29
00:02:01,080 --> 00:02:01,740
Okay.

30
00:02:02,860 --> 00:02:03,360
Okay.

31
00:02:03,370 --> 00:02:08,320
After that, I'm going to add an additional method, which is the post.

32
00:02:09,720 --> 00:02:11,790
So we will follow the same steps.

33
00:02:12,450 --> 00:02:18,270
Lambda function check these proxy integration and give the lambda function product function click.

34
00:02:18,390 --> 00:02:18,870
Say button.

35
00:02:18,870 --> 00:02:19,110
Click.

36
00:02:19,350 --> 00:02:20,160
Okay button.

37
00:02:21,420 --> 00:02:28,860
So now we have complete these get and post operation over the route name is a product and now we should

38
00:02:28,860 --> 00:02:32,310
create any resources on the product.

39
00:02:32,310 --> 00:02:36,150
So that means this will be the nested resources on the product.

40
00:02:36,150 --> 00:02:40,020
And after that we will create method for the get put and delete.

41
00:02:40,020 --> 00:02:41,640
So let's get started.

42
00:02:41,670 --> 00:02:46,800
I'm going to click the product resources, come to actions and create a name resources.

43
00:02:46,800 --> 00:02:53,220
So this will be the ID that provide the product ID information, create these resources.

44
00:02:53,550 --> 00:03:00,510
And under these resources I'm going to create a set of methods that will be start the gate method,

45
00:03:00,960 --> 00:03:06,870
click this icon and select lambda, check this box and give required lambda function.

46
00:03:06,870 --> 00:03:08,880
Click to say button, click the okay button.

47
00:03:09,090 --> 00:03:15,000
So I'm going to follow the same steps for the create method for put and delete.

48
00:03:21,050 --> 00:03:23,120
This is a HTTP operation.

49
00:03:23,450 --> 00:03:27,110
And now I'm going to create a new method.

50
00:03:27,320 --> 00:03:29,540
This will be the delete operation.

51
00:03:31,090 --> 00:03:33,070
So that means delete buy ID.

52
00:03:35,510 --> 00:03:37,400
Click disabled and click to okay button.

53
00:03:39,170 --> 00:03:44,780
As you can see that we have created five HTTP methods with the product and product by ID resources.

54
00:03:44,780 --> 00:03:52,190
So that means this API gateway can be triggered with the five invocation from the client application

55
00:03:52,190 --> 00:03:55,070
and this will be redirect to the product microservices.

56
00:03:55,070 --> 00:04:01,130
Product microservices should be automate all these requests and develop our actual logic, which is

57
00:04:01,130 --> 00:04:04,640
the performing operations over the product table on Dynamo.

58
00:04:04,640 --> 00:04:09,380
DB But we forgot the very important step which is the deploying the API.

59
00:04:09,380 --> 00:04:15,080
So without deploying the API, we don't expose APIs and create endpoints for that purpose.

60
00:04:15,080 --> 00:04:21,770
We come to actions and correctly deploy API button and this is required to new stage.

61
00:04:21,770 --> 00:04:25,310
We can give the stage name as a production and click the deploy button.

62
00:04:25,880 --> 00:04:28,850
So after that we will see that under the stage.

63
00:04:28,850 --> 00:04:33,440
We have a production environment stage that is impeccable.

64
00:04:33,440 --> 00:04:40,490
URL is generated from the A place and you can get every HTTP request operation from the inaugural of

65
00:04:40,490 --> 00:04:41,390
the stage.

66
00:04:41,750 --> 00:04:48,920
Under the stage section, you can see the we can provide the HTTP delete gate and put product by ID

67
00:04:48,950 --> 00:04:55,940
specifying ID and we can get and post operation with only product resources invoking this URL.

68
00:04:56,060 --> 00:05:00,200
So as you can see that we have successfully finished our infrastructure.

69
00:05:00,230 --> 00:05:05,000
Now it is time to start the developing with a JavaScript version three.
