- Newest
- Most votes
- Most comments
Based on the symptoms you're describing—immediate 500 errors with no Lambda invocation logs—this strongly suggests a permissions issue specific to the integration invocation path, even though your resource-based policy appears correct on the surface.
The key difference between the authorizer working and the integration failing is that API Gateway uses different invocation contexts for these two scenarios. When API Gateway invokes a Lambda authorizer versus invoking a Lambda integration, the source ARN pattern and permission requirements can be subtly different.
For HTTP APIs specifically, the resource-based policy condition should use a more specific ARN pattern. Your current wildcard pattern arn:aws:execute-api:us-east-2:<account-id>:<api-id>/*/*/* may be too broad or not matching the actual invocation context. Try granting permission with a more targeted condition:
aws lambda add-permission \
--function-name <function-name> \
--statement-id apigateway-invoke-permission \
--action lambda:InvokeFunction \
--principal apigateway.amazonaws.com \
--source-arn "arn:aws:execute-api:us-east-2:<account-id>:<api-id>/*/*"
Note the pattern ends with /*/* (stage and route) rather than /*/*/*. For HTTP APIs, the ARN structure differs slightly from REST APIs.
Additionally, enable access logging on your HTTP API stage to capture the $context.integrationErrorMessage variable. This will show you the exact error API Gateway encounters when attempting to invoke your Lambda function. Configure logging with a format that includes:
$context.integrationErrorMessage
$context.error.message
$context.error.responseType
Send the logs to a CloudWatch log group, make another request, and check the logs. The integration error message should reveal whether this is indeed a permission denial or another issue preventing invocation.
If the logs confirm a permission error, remove all existing Lambda permissions for API Gateway and add a fresh one with the corrected ARN pattern. Sometimes stale or conflicting permission statements can cause unexpected behavior even when the policy JSON looks correct.
Sources
Troubleshooting issues with HTTP API Lambda integrations - Amazon API Gateway
Invoking a Lambda function using an Amazon API Gateway endpoint - AWS Lambda
answered a month ago
Relevant content
asked a year ago
asked a year ago
- AWS OFFICIALUpdated a year ago
