Why am I getting “Execution failed due to configuration” errors from API Gateway after using a CloudFormation template or OpenAPI definition to create a REST API with a Lambda integration?

Last updated: 2021-11-11

I used an AWS CloudFormation template (or OpenAPI definition) to create an Amazon API Gateway REST API with AWS Lambda integration. When I try to invoke my Lambda function using the API method, I get the following error message and a 500 status code: "Execution failed due to configuration error." What's causing the error, and how do I troubleshoot the issue?

Short description

If you have an API Gateway REST API with Lambda integration, then the API must invoke the backend Lambda function using the HTTP method, POST. If you use any other HTTP method (for example, ANY or GET) for the backend integration request, then invocation fails. API Gateway then returns an error message similar to the following example in your Amazon CloudWatch 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 REST API's frontend.

You must specify the POST method for the backend integration request if you create a REST API with Lambda integration using any of the following:

If you use the API Gateway console to configure a Lambda integration, then the backend integration request is automatically set to POST.

Resolution

Note: If you receive errors when running AWS CLI commands, make sure that you're using the most recent version of the AWS CLI.

Change the HTTP method to POST for the backend integration request by doing one of the following, based on your use case:

To change the HTTP method to POST for a backend integration request using the API Gateway console

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

For more information, see Getting started with API Gateway and Set up an API integration request using the API Gateway console.

To change the HTTP method to POST for a backend integration request by updating your AWS CloudFormation template

  1. Set the IntegrationHttpMethod property value in your CloudFormation template to POST. For instructions, see Modifying a stack template.
  2. Update your API by updating your CloudFormation stack with the edited template.

To change the HTTP method to POST for a backend integration request by updating your OpenAPI definition

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