- Newest
- Most votes
- Most comments
Based on your description, it sounds like you're experiencing a 404 error from API Gateway despite your Lambda functions executing successfully. This is a common issue that can occur for several reasons.
Since you mentioned that the Lambda functions are executing correctly (as evidenced by CloudWatch logs) but you're still getting a 404 error, the issue is likely related to how API Gateway is handling the response from your Lambda function or how the integration is configured.
Here are some potential causes and solutions:
-
Lambda Response Format: Ensure your Lambda function is returning a response in the format that API Gateway expects. API Gateway requires a specific structure for Lambda proxy integrations.
-
Route Configuration: Verify that the API Gateway routes are correctly configured to match the endpoints you're calling. The 404 error suggests that API Gateway cannot find the route you're trying to access.
-
API Deployment: Check if you've deployed your API after making any recent changes. Until you deploy your API, the changes will not be live and accessible from the front end.
-
Lambda Permissions: Ensure your Lambda function has the necessary IAM permissions to be invoked by API Gateway. You need to add the
lambda:InvokeFunctionpermission to your API Gateway role. -
Integration Response Mapping: If you're using a non-proxy integration, check your integration response mappings to ensure they're correctly configured.
-
Logging Enhancement: Add more detailed logging in your API Gateway by including variables like
$context.error.message,$context.error.responseType, and$context.integrationErrorMessageto get more information about what's happening. -
API Gateway Stage: Confirm you're calling the correct stage of your API Gateway (e.g., prod, dev).
Since you mentioned that testing the API from specific resources works fine, it suggests that the issue might be related to how the client is calling the API or how certain routes are configured. The fact that disabling authentication doesn't resolve the issue further indicates that the problem is likely in the API Gateway configuration or the Lambda response handling, not in the authentication flow.
I recommend checking these areas systematically to identify and resolve the 404 error.
Sources
AWS Gateway: API does not respond in Postman | AWS re:Post
POST Request Made from Within Lambda Only Receiving a Not Found Response | AWS re:Post
Troubleshooting issues with HTTP API Lambda integrations - Amazon API Gateway
answered a year ago
Relevant content
asked 2 years ago
