Skip to content

Api gateway with lambda authorizer

0

I have a lambda authorizer and more than 10 APIs are using this lambda authorizer. And now I have added 1 more API to use this lambda authorizer. And in the execution logs I'm getting invalid permission on lambda function , when I check the triggers in lambda authorizer I'm getting An error occurred while listing Api gateway relations too many requests whether this is the reason why my newly added API is getting invalid permission. Note the previously added APIs are working fine with the lambda authorizer only the newly added getting invalid permission on lambda function

1 Answer
0

The issue you're experiencing with your newly added API getting an "invalid permission on lambda function" error, while previously added APIs continue to work fine, could be related to a few factors:

  1. API Gateway Permission: When you add a new API to use an existing Lambda authorizer, API Gateway needs permission to invoke that Lambda function for the new API. This permission is typically added automatically, but in some cases, it may fail or be delayed.

  2. Resource Policy: The Lambda function's resource policy might need to be updated to allow the new API Gateway to invoke it. If the policy has a limit on the number of statements or size, it might not be able to accommodate the new API.

  3. Rate Limiting: The error message "An error occurred while listing Api gateway relations too many requests" suggests that you might be hitting a rate limit when trying to list or update the API Gateway relationships. This could potentially interfere with the process of granting the necessary permissions for the new API.

To resolve this issue, you can try the following steps:

  1. Manually add the permission for the new API to invoke the Lambda authorizer. You can do this using the AWS CLI or by updating the Lambda function's resource policy in the AWS Console.

  2. If you're hitting rate limits, wait for a short period and try again. AWS often uses exponential backoff for rate-limited requests.

  3. Check the Lambda function's resource policy to ensure it's not at its maximum size or number of statements. If it is, you might need to consolidate existing statements or remove outdated ones.

  4. Verify that your AWS account limits haven't been reached for the number of resources or API calls in the relevant services.

  5. If the problem persists, you may need to contact AWS support for further assistance, as there could be an underlying issue with the API Gateway or Lambda service in your account.

Remember, while troubleshooting, it's a good practice to enable access logging for your API stage and include the $context.authorizer.error logging variable in your log format. This can provide more detailed information about the authorization errors you're encountering.

Sources
Control access to HTTP APIs with AWS Lambda authorizers - Amazon API Gateway
Api gateway resource policy and lambda authorizer | AWS re:Post

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.