Be an AWS lambda expert No.2 - How to expose lambda function as API endpoint using API Gateway service

We have created a lambda function using custom layer in the previous blog:

In order to use it, we have to expose it as an API endpoint using the API Gateway service.
First search the “API Gateway” in your AWS console like this:

Then click the “Create API” button like this:

Of the list of options, we can choose to build a REST API:

For “choose the protocal”, give the API a name and some description, and all the other options can be default:

Now we are ready to create a method as the following:

and we will choose to create a “POST” method as an example like this:

Now we are ready to integrate the lambda function we set up in the previous blog named as “gpt3_lambda” with this POST method as the following,
where we begin to type in the “Lambda Function” black space, and would see the options to choose the lambda function list:

As a last step, we should click “Actions” and choose the “Deploy API” from the drop down list:

Choose “[new state]” for the Deployment Stage, and give a name to that stage, such as “prod”, then hit the deploy button:

Now we will be successful, and just copy the url form the following screen shot, and use it somewhere!

Author: robot learner
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source robot learner !