Hi, I'm trying to build an api service. For exampl...
# help
m
Hi, I'm trying to build an api service. For example a image background removal service (just for example) I mean, my users will have an api key which they have to include with every request. It will be used to limit the users quota according to billing plans. I'm planning to use supabase for database and auth. Is there any way I can do this with STT?
f
Yeah in the Lambda, you just have to validate the user’s api key.
r
It’s also possible with the V1 Rest API to define a usage plan with an API key
m
@Frank do you mean create api key somewhere else and store it in supabase, Then use it to allocate api quota?
One doubt, if a user has already consumed all of his api credits for the month. Then he tries to use the api again. In that case we have to prevent them from using it. So we need an additional lambda for checking this?
Btw, Thank you Guys for everything 😇
@Ross Coundon I heard that there's a limit of 10000 or something for the total number of api keys a account can have?
r
Yes, 10000 per account per region "Amazon API Gateway quotas and important notes - Amazon API Gateway" https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
m
So it'll be better to manage them seperately.right? But then how can we control number of concurrent invocations?
r
It's probably worth describing your exact use case as the need for more than 10000 API keys seems excessive and there may be a better architecture or approach
m
Ok. Lemme explain. I'm building a form handling service like formspree.io I know there are a million alternatives to this. But i think this will be a huge learning oppertunity for me
Ie. Normally these services use api key to identify and limit users
So thats what I'm trying to accomplish
r
OK, so if you're expecting to surpass 10k users, or for simplicity and to use the Http API you could create a lambda authorizer that looks up a supplied header value in a database to check what the user is allowed to access.
f
+1 Ross. @Muhammed Mukhthar CM you can store the API key in supabase (or DynamoDB, whichever is easier for u), and when ur Lambda handler receives the request, make a call to the DB to validate the key.
m
Thank you @Ross Coundon @Frank 😇 😇 Lemme build it. I will inform you if I get stuck in the way.🙂