In this video, we are going to create a rest API in API gateway when our API method receives an HTTP
request, API Gateway invokes our lambda function.
So to create a rest API, please open the mail console.
Go to API gateway.
And we will create a new API gateway.
Which type is the API?
Choose the type is a rest API.
Click the boot button and this will be a rest API.
We are going to create an API.
Please select an API and give the name as a product API and leave the default configurations.
Click the create button.
So after created the waste API, we are going to create resources and methods.
So in order to do that, come here, click actions, create resources.
Which name is product?
I'm going to create a product resources to manage product microservices and click to create resource
method.
So now after creating a resource, we should create methods.
In order to do that, I'm going to click the resource name and click the Actions Create Method, which
will be the guest.
Click this icon to create a get method and this will be the lambda function integration type and we
can use the proxy integration.
This is important.
You should check this box and after that provide this lambda function which is the product function.
Click the save button and this is required permissions to invoke lambda function plus give required
permission click the OC and this get operation is finished.
Now we will do it for the post operation.
Now let's create a post method, select the resource actions, create method and this should be the
post click the OC and the integration type will be lambda function.
And please don't forget to check this use lambda proxy integration.
This is very important, otherwise you get exception.
So a lambda function should be the product function and select the save button and give the required
permission with OC operation.
Okay.
Now as you can see that we have create a post operation, this will be also integrate with the lambda
function, which name is product function.
So I'm going to continue with the get buy ID and delete my idea for that purpose.
Select the resource actions.
This time we are going to create resource under the product resource for that purpose.
I'm going to the ID statement in here.
This will be the resource pet for ID information that we can get a pet parameters.
This ID information create resources and this will be created under the product resources and with ID
information we can go to actions and create method.
Under the ID we can get buy ID operation.
You can click the get method and select the same configuration.
This will be applied to get by.
ID give the required permissions and the same way I'm going to go to actions create method.
This time this will be the http delete.
So that means delayed by ID again the lambda function.
Check this box and come to product function and click this button and click okay.
Okay.
In the last step, we need to deploy the API so that we can access through the public URL.
For that purpose, come to the actions and you can see the deploy API button.
Click to deploy API.
In this deployment stage, we should create a deployment stage.
So I'm going to give a stage name as a production and click the deploy button.
So now as you can see that we have deployed this rest API successfully, now it is ready for the get
request from this URL.
You can get a specific URL from the get product post product and delete my ID and get my ID operations.