Creating an API Gateway

The following screenshots depict the creation, configuration and integration of an API Gateway.

From the dashboard of the API Gateway, create an API named Greeter, as follows:

Create a resource named greeter, as follows:

Create a resource, /, to handle the HTTP POST request. Notice that we specify the integration type to the Lambda function, and select Greeter, the function that we created in the previous sections, to be invoked. Also, notice that we leave the Use Lambda Proxy integration box unchecked. This means that we are choosing this integration to be of the Lambda type:

Once the POST resource is created, you will see a pictorial representation of how the integration of the API Gateway and AWS Lambda works. Since we have chosen the Lambda integration type, we can see four configuration stages in the flow that can be configured separately, as follows:

  • Method Request: This is the configuration that deals with the requests received by the API Gateway from the client. One can configure request validations, URL param validations, and the request body to models mapping in this stage.
  • Integration Request: This is the configuration that deals with the request that is passed to the Lambda from the API Gateway. One can configure the mapping of the URL params, request body, and header transformation to an appropriate structure that your Lambda function expects.
  • Integration Response: This is the configuration that deals with responses from the Lambda returned to the API Gateway. One can transform the Lambda output to appropriate HTTP error codes that are relayed back to the API Gateway.
  • Method Response: This is the configuration that deals with the response from the API Gateway to the client. One can attach HTTP error codes to their respective response bodies and modify the response headers that are to be returned to the client: