Menu
Amazon API Gateway
Developer Guide

Set up API Gateway Integration Request

The settings of an API method defines the method and describes its behaviors. To create a method, you must specify a resource, including the root (“/”), on which the method is exposed, a method type (GET, POST, etc.), and how it will be integrated with the targeted backend. The method request and response specify the contract with the calling app, stipulating which parameters the API can receive and what the response looks like. The integration request and response specifies how API Gateway interacts with their backend: enforcing secure communications over HTTPS with the backend and translating data formats between the client and backend. The following topics describe how to use the API Gateway console to specify a method settings.

  1. In the Resources pane, choose the method.

  2. In the Method Execution pane, choose Integration Request. For Integration type, choose one of the following:

    • Choose Lambda Function if your API will be integrated with a Lambda function. At the API level, this is an AWS integration type.

    • Choose HTTP if your API will be integrated with an HTTP endpoint. At the API level, this is the HTTP integration type.

    • Choose AWS Service if your API will be integrated directly with an AWS service. At the API level, this is the AWS integration type. The Lambda Function option above is a special case of the AWS integration for invoking a Lambda function and is available only in the API Gateway console. To set up an API Gateway API to create a new Lambda function in AWS Lambda, to set a resource permission on the Lambda function, or performing any other Lambda service actions, you must choose the AWS Service option here.

    • Choose Mock if you want API Gateway to act as your backend to return static responses. At the API level, this is the MOCK integration type. Typically, you can use the MOCK integration when your API is not yet final, but you want to generate API responses to unblock dependent teams for testing. For the OPTION method, API Gateway sets the MOCK integration as default to return CORS-enabling headers for the applied API resource. If you choose this option, skip the rest of the instructions in this topic and see Configure Mock Integration for a Method.

  3. If you chose Lambda Function, do the following:

    1. For Lambda Region, choose the region identifier that corresponds to the region where you created the Lambda function. For example, if you created the Lambda function in the US East (N. Virginia) region, you would choose us-east-1. For a list of region names and identifiers, see AWS Lambda in the Amazon Web Services General Reference.

    2. For Lambda Function, type the name of the Lambda function, and then choose the function's corresponding ARN.

    3. Choose Save.

  4. If you chose HTTP, do the following:

    1. For HTTP method, choose the HTTP method type that most closely matches the method in the HTTP backend.

    2. For Endpoint URL, type the URL of the HTTP backend you want this method to use.

    3. Choose Save.

  5. If you chose Mock, do the following:

    • Choose Save.

  6. If you chose AWS Service, do the following:

    1. For AWS Region, choose the AWS region you want this method to use to call the action.

    2. For AWS Service, choose the AWS service you want this method to call.

    3. For AWS Subdomain, type the subdomain used by the AWS service of your interest. Typically, you would leave this blank. Some AWS services can support subdomains as part of the hosts. Consult the service documentation for the availability and, if available, details.

    4. For HTTP method, choose the HTTP method type that corresponds to the action. For HTTP method type, see the API reference documentation for the AWS service you chose for AWS Service.

    5. For Action, type the action you want to use. For a list of available actions, see the API reference documentation for the AWS service you chose for AWS Service.

    6. For Execution Role, type the ARN of the IAM role the method will use to call the action.

      To create the IAM role, you can adapt the instructions in "To create the Lambda invocation role and its policies" and "To create the Lambda execution role and its policy" in the Create Lambda Functions section of the Build an API to Expose a Lambda Function; and specify an access policy of the following format, with the desired number of action and resource statements:

      Copy
      { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "action-statement" ], "Resource": [ "resource-statement" ] }, ... ] }

      For the action and resource statement syntax, see the documentation for the AWS service you chose for AWS Service.

      For the IAM role's trust relationship, specify the following, which enables API Gateway to take actions on behalf of your AWS account:

      Copy
      { "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "apigateway.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }
    7. If the action you typed for Action provides a custom resource path you want this method to use, for Path Override, type this custom resource path. For the custom resource path, see the API reference documentation for the AWS service you chose for AWS Service.

    8. Choose Save.

  7. Do both of the following:

    • Specify how the method will receive requests from, and send responses to, callers (which API Gateway refers to as the API's method request/response), and how the method will authorize requests by following the instructions in Set up Method Request.

    • Specify how the method will send requests to, and receive responses from, the Lambda function, HTTP proxy, or AWS service proxy (which API Gateway refers to as the API's integration request/response) by following the instructions in Set up Data Mappings between Method and Integration.