1
00:00:00,360 --> 00:00:01,440
In this video.

2
00:00:01,470 --> 00:00:04,620
We are going to continue to our hands on loop in this video.

3
00:00:04,620 --> 00:00:10,470
We will create an HTTP API for our hands on loop, which is a microservice HTTP API.

4
00:00:10,680 --> 00:00:18,510
So we will in this step, we will create a HTTP API and we will create a API to integrate a lambda and

5
00:00:18,510 --> 00:00:22,950
create roles with the product microservices, get post and delete operations.

6
00:00:22,950 --> 00:00:24,720
So let's get started.

7
00:00:24,900 --> 00:00:32,460
In order to do that, please open the management console and go to the API Gateway section and API Gateway

8
00:00:32,460 --> 00:00:32,820
section.

9
00:00:32,820 --> 00:00:34,830
You can choose an API.

10
00:00:34,860 --> 00:00:41,040
As you can see, that API Gateway also supports rest APIs and web socket APIs, but HTTP API is the

11
00:00:41,040 --> 00:00:48,050
best choice for this exercise because HTTP API have lower latency and lower cost than the rest APIs.

12
00:00:48,120 --> 00:00:53,760
We have to look at APIs, maintain positions in connection with clients for full duplex communication,

13
00:00:53,760 --> 00:00:55,860
which isn't required for this example.

14
00:00:55,950 --> 00:01:01,770
So the HTTP API provides the provides to HTTP end point for our lambda function.

15
00:01:01,770 --> 00:01:06,750
So API gateway routes the request to our lambda function, then returns back to function response to

16
00:01:06,750 --> 00:01:14,910
client in order to create a HTTP API, choose HTTP API and click the boot button and you can see that

17
00:01:14,910 --> 00:01:18,300
there is a visit in here that we are going to follow.

18
00:01:18,450 --> 00:01:21,870
And in this visit, starting with the integration configuration.

19
00:01:21,870 --> 00:01:27,720
So for integration, I'm going to add integration and this time we will use Lambda again.

20
00:01:27,720 --> 00:01:34,470
So we have created Lambda Function in the last video, please select the product function, lambda function

21
00:01:34,470 --> 00:01:35,160
in here.

22
00:01:35,160 --> 00:01:39,990
So after that, scroll down and give the name of the our API.

23
00:01:40,170 --> 00:01:42,450
We are going to product cloud microservices.

24
00:01:42,450 --> 00:01:47,670
So that's why I'm giving the product this API and click the next button.

25
00:01:48,360 --> 00:01:50,580
The second configuration is configured.

26
00:01:50,580 --> 00:01:55,890
What routes are a way to send incoming API requests to the backend resources?

27
00:01:56,010 --> 00:02:01,590
Roles consist two parts and HTTP method and also resource part.

28
00:02:01,680 --> 00:02:08,550
If you come back to our design, you can see that these are the HTTP methods and our resource paths.

29
00:02:08,550 --> 00:02:15,690
So we will follow these route definitions and create these forward definitions into our API gateway

30
00:02:15,690 --> 00:02:19,110
to perform CRUD operations for product microservices.

31
00:02:20,100 --> 00:02:27,250
For that purpose, please go back to configure site and start to create one by one.

32
00:02:27,270 --> 00:02:31,860
For example, I can remove this one and create from scratch.

33
00:02:31,890 --> 00:02:36,510
So let's start with the get slash product.

34
00:02:38,880 --> 00:02:44,430
And give the integration target is the product function is the same way I'm going to follow the other

35
00:02:44,430 --> 00:02:50,340
configuration get product slash this time I'm putting in here.

36
00:02:51,510 --> 00:02:52,170
ID.

37
00:02:54,240 --> 00:02:55,020
Okay.

38
00:02:56,010 --> 00:03:01,510
Every integration should be looked to a product function, lambda function, and I'm going to continue

39
00:03:01,560 --> 00:03:06,480
to post operation to create product and product function.

40
00:03:06,480 --> 00:03:12,800
And last time I'm going to add the HTTP delete operation in order to delete a specific product with

41
00:03:12,810 --> 00:03:13,440
ID.

42
00:03:13,920 --> 00:03:14,580
Okay.

43
00:03:14,760 --> 00:03:19,920
So for the pet, we should enter product and slash ID information.

44
00:03:19,920 --> 00:03:27,060
The ID at the end of this pet is the pet parameter that API gateway retrieves from the request from

45
00:03:27,060 --> 00:03:29,760
the pet one client make a request.

46
00:03:29,760 --> 00:03:35,730
For example, we will send the request products like six or seven and we get these ID information and

47
00:03:35,730 --> 00:03:39,390
remove or get specific product from the database.

48
00:03:39,540 --> 00:03:40,090
Okay.

49
00:03:40,110 --> 00:03:46,620
So if you look at our integrations, you can see that our integration targets all indicated to product

50
00:03:46,620 --> 00:03:47,880
function, lambda function.

51
00:03:47,880 --> 00:03:51,480
We create an integration to connect a raw to the backend resources.

52
00:03:51,480 --> 00:03:57,210
For this example API, we create one lambda integration that we use for all routes.

53
00:03:57,210 --> 00:04:03,540
After we attach the integration to all of the API struts or lambda function, which is the product function

54
00:04:03,540 --> 00:04:07,200
is invoked when a client calls of any of our routes.

55
00:04:07,200 --> 00:04:14,340
So we will accommodate and incoming these HTTP methods into our product function and develop our business

56
00:04:14,340 --> 00:04:17,910
logic to perform CRUD operations with communicating dynamo.

57
00:04:17,910 --> 00:04:24,420
DB So okay, if you click the next button, the another configuration is states.

58
00:04:24,420 --> 00:04:29,100
States are independently configurable environment that our API can be deployed.

59
00:04:29,130 --> 00:04:35,460
We have to deploy a stage for API configuration change to take effect unless the stage is configured

60
00:04:35,460 --> 00:04:37,260
or to deploy it by default.

61
00:04:37,260 --> 00:04:40,110
All HTTP API is created through the console.

62
00:04:40,140 --> 00:04:43,260
Have a default stage name which name is default?

63
00:04:43,410 --> 00:04:49,650
And the auto deployment is on leave as it is and continue with the default stage and select auto deploy

64
00:04:49,650 --> 00:04:50,520
configuration.

65
00:04:50,520 --> 00:04:55,050
And if you click the next button, we can see the review and create section.

66
00:04:55,050 --> 00:05:03,420
We can retrieve and create API gateway, see the raw definitions as we have designed from the our architecture.

67
00:05:03,450 --> 00:05:04,500
You can see that.

68
00:05:04,500 --> 00:05:08,100
So see the stage, see the API name and integrations.

69
00:05:08,100 --> 00:05:13,350
It if everything is goes well now we are going to create our HTTP API.

70
00:05:14,550 --> 00:05:19,950
Click the create button and we have created API, HTTP API with lambda integration that's ready to receive

71
00:05:19,950 --> 00:05:21,810
request from the client application.

72
00:05:21,900 --> 00:05:23,970
So now we can check the console.

73
00:05:24,000 --> 00:05:27,390
We can also see details on a management console.

74
00:05:27,420 --> 00:05:30,120
Go to APIs and go to our API.

75
00:05:31,080 --> 00:05:32,100
You can see that.

76
00:05:32,100 --> 00:05:34,430
We can see the details in here.

77
00:05:34,440 --> 00:05:38,460
The name is the product API and you can see the API details in here.

78
00:05:38,880 --> 00:05:42,120
And here you can see the stage for our product API.

79
00:05:42,150 --> 00:05:45,540
We have default stage name and this is the inaugural date.

80
00:05:45,540 --> 00:05:49,590
We can invoke our HTTP API to integrate with the lambda function.

81
00:05:50,990 --> 00:05:54,730
And also you can come here and see the develop section.

82
00:05:54,740 --> 00:06:01,760
Under the develop section we have rods and we have defined for what we can see that these the product

83
00:06:01,760 --> 00:06:08,120
post and get and the products ID have also get and delete methods.

84
00:06:08,120 --> 00:06:15,530
We can also see all configurations in here and you can also attach the authorization and integrate change

85
00:06:15,530 --> 00:06:16,790
the integration in here.

86
00:06:16,820 --> 00:06:18,470
We will see in the upcoming videos.

87
00:06:18,470 --> 00:06:24,860
But the idea is that you have to make sure that you design your architecture according to our design

88
00:06:25,490 --> 00:06:33,080
product, microservices and methods and we have verified with the A console and now it is time to test

89
00:06:33,080 --> 00:06:34,190
our API.

90
00:06:34,520 --> 00:06:38,030
Next, we test our API to make sure that it's working.

91
00:06:38,060 --> 00:06:45,230
In order to do that, I'm going to create the API method and again I'm going to use the inaugural right

92
00:06:45,230 --> 00:06:51,650
click open meetup is you remember that when we call this inaugural this is returning the message not

93
00:06:51,650 --> 00:06:55,160
want because there is no real definition in this URL.

94
00:06:55,190 --> 00:07:02,480
To do that we have to append some raw definitions in the last time we have append the lambda function

95
00:07:02,480 --> 00:07:05,060
name, but this time we have raw definition.

96
00:07:05,060 --> 00:07:09,890
So in order to do that, for example, I would like to send get product request.

97
00:07:09,920 --> 00:07:15,110
In order to do that, I'm going to copy this slash product definition and come here.

98
00:07:16,280 --> 00:07:24,470
And this time we are going to center get method and these sent to get product method and if we hit enter

99
00:07:24,500 --> 00:07:29,420
this will be direct to the request to the lambda function and lambda function return vectors.

100
00:07:29,420 --> 00:07:30,680
Hello from Lambda.

101
00:07:30,680 --> 00:07:37,280
So our browser sends a request to the API, but we should give the right raw definition to invoke our

102
00:07:37,280 --> 00:07:38,270
function properly.

103
00:07:38,390 --> 00:07:42,560
So we give this product and this is redirect to a lambda function.

104
00:07:42,560 --> 00:07:45,710
Now we can verify our API response is working.

105
00:07:45,710 --> 00:07:53,360
Well, we should see this halo from text in your browser and we have verified our http api design is

106
00:07:53,360 --> 00:07:57,800
expected in this picture and it is return back to message from the lambda.
