I'm using AWS API Gateway and Lambda to upload images to an S3 bucket. I have setup API Gateway to use a custom authoriser.
I'm currently passing the base64 encoded image in the JSON payload (not ideal but for the moment it is fine for what I need).
This is how I call my API (note you need jq and httpie installed to issue this call):
base64 <my_image> | jq -R '{image: .}' | http https://<api_gw_url>/dev/upload 'Authorization:Bearer <my_auth_token>'
If I issue more than once the same request, API Gateway returns a 200 the first time (and the document is correctly uploaded), but for any subsequent request (with the same auth token to the same URI) a 403 Forbidden is returned with the following error in the body:
{
"Message": "User is not authorized to access this resource"
}
After about 5min the request is accepted again :/
I didn't find any mention of default rate limiting in the documentation.
I have also tried to add a Usage Plan, with an API Key associated, to be able to tweak the rate limiting, but it didn't make any difference.
Did anybody else experienced this?
Edit
Just wanted to add some more info about my architecture to make sure the issue is better explained.
My setup includes an API Gateway, a Lambda that takes care of the authorization with JWT and another Lambda that does the upload to S3. What happens is the following:
First call
>base64 <my_image> | jq -R '{image: .}' | http https://<api_gw_url>/dev/upload 'Authorization:Bearer <my_auth_token>'
Request hits:
- API Gateway
- Authorization Lambda
- Document Upload Lambda
Response code: 200
Second call (issued less than 5 min after the first one)
>base64 <my_image> | jq -R '{image: .}' | http https://<api_gw_url>/dev/upload 'Authorization:Bearer <my_auth_token>'
Request hits:
- API Gateway
Request does NOT hit:
- Authorization Lambda
- Document Upload Lambda
Response code: 403