Monthly Archives: January 2018

Troubleshooting tips for Amazon AWS API Gateway

Published / by Steve

These are some troubleshooting tips based on what I’ve picked up after a couple of rounds of using the API Gateway to create RESTful endpoints for Lambda nanofunctions.

1. Redeploy your API. This probably needs to be done to make changes visible if you’re testing with curl or a browser, and it has resolved some mysterious issues.

2. If you’re seeing permission issues such as “Execution failed due to configuration error: Invalid permissions on Lambda function”, the thread at https://forums.aws.amazon.com/thread.jspa?messageID=800375 has a number of potential fixes to try.

What worked for me was re-selecting my Lambda, so that the permission was set automagically on the second try. To do this go to the API Gateway web UI and click on Integration Request. In the Lambda Function field delete the current value, then choose the same one as before. Be sure to click the little down arrow, or maybe it’s a checkmark, next to the lambda name. When I did this it brought up a popup I had not seen before:

Add Permission to Lambda Function
You are about to give API Gateway permission to invoke your Lambda function:
arn:aws:lambda:us-east-1:723707654321:function:FetchZipCodeLambda

I happily told it to give permission, and the error went away.

3. If you don’t have any error messages, configure logging for the API Gateway, which is off by default. Follow the directions at https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudwatch-logs/ carefully, except always redeploy your API afterwards.

The logs are in AWS CloudWatch. Go the web UI and in Log Groups look for a group where the name starts with “API-Gateway-Execution-Logs”. Then look for Log Streams with a Last Event Time, which should have useful information. If you don’t see any try hitting your endpoint a few times, then check again.

4. When in doubt, redeploy your API and try again.