1
00:00:00,360 --> 00:00:06,120
In this video, we are going to getting started with API Gateway HTTP APIs.

2
00:00:06,360 --> 00:00:07,830
Let's get started.

3
00:00:07,860 --> 00:00:12,570
First of all, we create a lambda function using a lambda console.

4
00:00:12,600 --> 00:00:16,980
After that, we create an HTTP API using the API gateway console.

5
00:00:17,010 --> 00:00:20,640
Then we invoke our API from the client application.

6
00:00:20,670 --> 00:00:26,230
When we invoke our HTTP API API gateway reports to the request to the our lambda function.

7
00:00:26,250 --> 00:00:29,790
Lambda runs the lambda function and returns a response to the API.

8
00:00:29,790 --> 00:00:34,140
Gateway API gateway then returns to the response to the client users.

9
00:00:34,740 --> 00:00:36,240
Okay, let's get started.

10
00:00:36,270 --> 00:00:40,750
Please open the Asian console and go to the lambda functions.

11
00:00:40,770 --> 00:00:44,430
We use the lambda function for a back end of our API.

12
00:00:44,460 --> 00:00:48,460
For this example, I'm going to use default node.js example.

13
00:00:48,480 --> 00:00:54,750
Please create a function and give the function name my http.

14
00:00:55,790 --> 00:00:56,510
Function.

15
00:00:57,580 --> 00:01:06,190
ATP API function OC runtime will be Node.js and the function name is in here and the permissions all

16
00:01:06,280 --> 00:01:09,250
congregations leave as it is and create function.

17
00:01:10,180 --> 00:01:12,400
So the example function will be returned.

18
00:01:12,400 --> 00:01:17,080
A 200 response to the client application and the text will be the hello from Lambda.

19
00:01:17,590 --> 00:01:23,590
As you remember, that is the default lambda function code should look similar with our expectations.

20
00:01:23,620 --> 00:01:28,330
Okay, if you scroll down, if you see the code section, you can understand what I mean.

21
00:01:28,330 --> 00:01:33,010
We basically return back to response and the text message and the source code.

22
00:01:33,130 --> 00:01:38,980
Okay, now we can go opposite the second step, which is the create and HTTP API for that purpose.

23
00:01:38,980 --> 00:01:45,250
You can right here API gateway and after that you can click the start button and add the favorites.

24
00:01:45,250 --> 00:01:49,900
By this way, you can click this API gateway and directly go to API Gateway page.

25
00:01:50,350 --> 00:01:56,620
And in order to create our first API for the HTTP API, we can choose the API types.

26
00:01:56,620 --> 00:02:03,340
You can see in here is you remember that we have API types, which is the HTTP API, web socket API,

27
00:02:03,370 --> 00:02:06,130
rest API and we have private rest API.

28
00:02:06,130 --> 00:02:10,200
So basically in this example, we will create an HTTP API.

29
00:02:10,240 --> 00:02:18,610
Please click the boot button and we have several steps that we going to implement for the create HTTP

30
00:02:18,610 --> 00:02:19,240
API.

31
00:02:19,420 --> 00:02:23,020
As you can see that there is starting with the integrations.

32
00:02:23,020 --> 00:02:28,540
If you click the ADD integration, we basically choose a lambda function and we have just created the

33
00:02:28,540 --> 00:02:29,200
lambda function.

34
00:02:29,200 --> 00:02:31,540
Which name is my HTTP API function?

35
00:02:31,810 --> 00:02:34,810
Please select this one and add this integration.

36
00:02:35,660 --> 00:02:36,260
Okay.

37
00:02:36,260 --> 00:02:40,490
So we can add one more integration, but it is enough for now.

38
00:02:40,520 --> 00:02:47,330
If you can see that we can add one more integration, but I have only one lambda function and one vacant

39
00:02:47,330 --> 00:02:56,570
lambda function to integrate our HTTP to give the name of the HTTP my API and click the next button.

40
00:02:56,720 --> 00:02:59,480
Now we are going to review the roots.

41
00:02:59,510 --> 00:03:01,460
As you can see that I'm not going to change.

42
00:03:01,460 --> 00:03:08,000
For now, we can edit the Roots with adding methods for get post and page, so on.

43
00:03:08,000 --> 00:03:15,590
So we select the any and rows resource that is in here and integration type is the lambda function and

44
00:03:15,590 --> 00:03:18,860
click the next button and now we are going to review the states.

45
00:03:18,950 --> 00:03:23,700
As you remember that it is creating a default state and also deployment is on.

46
00:03:23,720 --> 00:03:30,140
Just click the next button and now we are review and create our first HTTP API.

47
00:03:30,170 --> 00:03:33,780
Click the create button and this will be create our HTTP API.

48
00:03:33,800 --> 00:03:39,740
Now we have created an API with a lambda integration that's ready to receive request from the client

49
00:03:39,740 --> 00:03:40,610
application.

50
00:03:40,610 --> 00:03:44,810
So the step three is testing our API.

51
00:03:45,050 --> 00:03:49,330
Next, we test our API to make sure that it is working.

52
00:03:49,340 --> 00:03:56,780
For simplicity, we can use a web browser to invoke our API, so choose your API and not this URL.

53
00:03:56,780 --> 00:03:57,950
You can see there the invoke.

54
00:03:58,610 --> 00:04:04,580
So for that purpose I am going to come to invoke URL and I'm going to right click and open it up.

55
00:04:04,580 --> 00:04:07,370
This will be invoke our http api.

56
00:04:07,400 --> 00:04:08,890
We are the web browser.

57
00:04:08,900 --> 00:04:09,740
So.

58
00:04:11,110 --> 00:04:15,280
If you click in here, you can see that the message is not font.

59
00:04:15,790 --> 00:04:23,230
We copy our API and enter the web browser, but this time we also need to obtain the name of our API

60
00:04:23,230 --> 00:04:27,160
Lambda function to invoke the URL to call your lambda function by default.

61
00:04:27,160 --> 00:04:32,200
The API gateway console creates a dot with the same name of our lambda function, which is my function

62
00:04:32,200 --> 00:04:33,040
for example.

63
00:04:33,190 --> 00:04:41,320
So in order to invoke our lambda function route so we should append the function lambda function name

64
00:04:41,320 --> 00:04:42,430
into the URL.

65
00:04:42,700 --> 00:04:47,140
To understand the URL, you can come here and come to the integrations.

66
00:04:47,170 --> 00:04:50,320
You can see that the integration is set up to my function.

67
00:04:50,320 --> 00:04:56,650
You can copy this function name and come to these APIs and invoke URL.

68
00:04:56,650 --> 00:05:04,270
And if you copy the inaugural and slash append the my HTTP function, which is the lambda function name

69
00:05:04,270 --> 00:05:05,320
and hit enter.

70
00:05:05,350 --> 00:05:12,220
This time we can invoke our lambda function over the API gateway and it is return back the hello from

71
00:05:12,220 --> 00:05:13,120
lambda function.

72
00:05:13,450 --> 00:05:21,010
So this is the how we can invoke lambda function over the HTTP API and we design our API in here and

73
00:05:21,010 --> 00:05:25,870
we can see what's authorization, integration, all the tests in here.

74
00:05:25,900 --> 00:05:32,650
Another important configuration is course you can come here and click the code section.

75
00:05:32,650 --> 00:05:35,770
So with one click we can also enable the course.

76
00:05:35,770 --> 00:05:39,370
The default course configuration will allow all origins.

77
00:05:39,370 --> 00:05:43,270
Then I'll add more granular control after creating the function.

78
00:05:43,270 --> 00:05:48,790
In case you are not familiar with the course, it is a header based security mechanism implemented by

79
00:05:48,790 --> 00:05:54,910
browsers to make sure that only certain hosts are allowed to load resources and invoke APIs.

80
00:05:55,030 --> 00:06:01,120
If a website is allowed to consume our API, we will need to include a of course headers that declare

81
00:06:01,120 --> 00:06:05,410
which Origin's methods and other custom headers are allowed.

82
00:06:05,410 --> 00:06:10,870
So if you go to code section, you can go to course and configurations.

83
00:06:10,870 --> 00:06:13,060
You can see that there is no configuration now.

84
00:06:13,060 --> 00:06:17,530
So that means now it is accepting all incoming requests to our core settings.

85
00:06:17,530 --> 00:06:22,780
If you click the configure button, we can configure our course settings in here.

86
00:06:22,780 --> 00:06:29,500
We can see the access control L0 Origins, expose headers, allow headers and load methods.

87
00:06:29,500 --> 00:06:37,390
We can, for example, give the allow only get methods and click the save and we have verified that

88
00:06:37,390 --> 00:06:39,400
only HTTP gate method are accepted.

89
00:06:39,400 --> 00:06:46,090
If you come here and refresh the page, you can see that these message comes from the HTTP gate method.

90
00:06:46,240 --> 00:06:47,020
So.

91
00:06:47,890 --> 00:06:54,250
As you can see that we have seen how configured API, gateway, HTTP API and integrate with the lambda

92
00:06:54,250 --> 00:06:54,910
function.

93
00:06:54,970 --> 00:06:57,610
Now it is time to clean up our resources.

94
00:06:57,610 --> 00:07:01,810
So please go to the API and come to my API.

95
00:07:01,840 --> 00:07:05,770
Click the actions and click delete button and delete our API.

96
00:07:06,340 --> 00:07:14,470
Okay, now we have delete our HTTP API and we have also should delete our lambda function because this

97
00:07:14,500 --> 00:07:16,600
API is integrated with the lambda function.

98
00:07:16,600 --> 00:07:22,570
Please go to lambda actions and delete confirm with the delete message and click the dead button.

99
00:07:22,960 --> 00:07:27,610
So we have to do this clean operation in order to prevent unnecessary cost.

100
00:07:28,180 --> 00:07:30,610
In the next video we are going to be hands on labs.
