I created an API Gateway API with Lambda integration by using AWS CloudFormation or OpenAPI (Swagger). Why do I get a generic "Execution failed due to configuration" error and a 500 status code when I try to invoke the API method?

Last updated: 2019-10-16

I used an AWS CloudFormation template or OpenAPI (Swagger) definition to create an Amazon API Gateway API with AWS Lambda integration. When I try to invoke the API method, my function fails to invoke and I get a generic "Execution failed due to configuration error:" message and 500 status code. Why am I getting this error?

Short Description

When you have API Gateway API with Lambda integration, the API must invoke the backend Lambda function using the HTTP method POST. If you use any other HTTP method (such ANY or GET) for the backend integration request, invocation fails and you see an error message like this in the logs:

Mon Oct 14 14:08:49 UTC 2019 : Received response. Status: 403, Integration latency: 3 ms
Mon Oct 14 14:08:49 UTC 2019 : Endpoint response headers: {Date=Mon, 14 Oct 2019 14:08:49 GMT, Content-Length=130, Connection=keep-alive, x-amzn-RequestId=abc1d2ef-34ab-56c7-de8f-90123a456789}
Mon Oct 14 14:08:49 UTC 2019 : Endpoint response body before transformations: <AccessDeniedException>
<Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>
Mon Oct 14 14:08:49 UTC 2019 : Lambda invocation failed with status: 403. Lambda request id: abc1d2ef-34ab-56c7-de8f-90123a456789
Mon Oct 14 14:08:49 UTC 2019 : Execution failed due to configuration error:
Mon Oct 14 14:08:49 UTC 2019 : Method completed with status: 500

Note: You can still set up any HTTP method for your API's frontend.

When you use the API Gateway console to configure a Lambda integration, it sets the backend request as POST for you. However, you must specify the POST method yourself when you create an API with Lambda integration using a CloudFormation template, an OpenAPI definition, or the AWS Command Line Interface (AWS CLI).

Resolution

Change the HTTP method to POST for the backend integration request by doing one of the following:

Use the API Gateway console

  1. In the API Gateway console, choose your API.
  2. In the Resources pane, choose the HTTP method with the Lambda integration.
  3. In the Method Execution pane, choose Integration Request.
  4. In the Integration Request pane, for HTTP method, choose POST, and then choose the check mark icon (Update).
  5. Deploy your API.
  6. (Optional) Test the HTTP method with the Lambda integration.

For more information, see Create a REST API with Lambda Integrations in Amazon API Gateway and Set up an API Integration Request Using the API Gateway Console.

Update your AWS CloudFormation template

If you created your API using a CloudFormation template, do the following:

  1. Update the template, setting the IntegrationHttpMethod property value to POST.
  2. Update the AWS CloudFormation stack with the template. This action updates your API.

Update your OpenAPI definition

If you created your API using an OpenAPI definition, do the following:

  1. Update the API definition, setting the httpMethod property value to POST. For more information, see x-amazon-apigateway-integration Object and the example Swagger template on the aws-samples GitHub repository.
  2. Update your API by importing the updated API definition file into API Gateway.